|
|
Try this if you have WA18: 10 7 3 0 5 9 2 3 7 3 1 4 4 The answer is: 12 1 8 + 1 8 + 4 1 + 9 6 + 2 9 - 2 9 - 3 10 - 6 3 - 6 3 - 6 3 - 6 3 - 6 3 - My solution falls on test 29. I have AC. My calculation of some values was wrong.:( TLE27???????????????? как исправить I don't know, what's wrong with my code. Who knows what's the trap? My AC solution gets WA test 29 if I replace `long` with `short int` (short int is 2 bytes, long is 4) P.S. You've got AC, so maybe you'd write what your problem was, to help anyone? Edited by author 04.02.2006 06:51 Okay, I got AC. But I still don't know, what was wrong with test 23. First I tried to solve this problem by solving Hauss equations very accurately. It works very fast, but it didn't pass the 23 test. After that I rewrote the code. Now I solved 'the rings' directly. It's much slower, but it got AC. The hints are: Start with the first knight and put the numbers 1, 1+K,1+2*K,etc. in a buffer, until you reach the first knight again. These knights form a ring, as I call it. They are served by servant in a form of a ring and don't intersect with other knights. So you can check them separately (the problem, therefore, can be separated in few parts). Now, let us denote: X[i] - the number of goblets brought to the i-th and (i+K)-th knight (don't forget, that i+K maybe more that N and use modulus). Therefore we can say that: X[i]+X[i+K]=F-A[i+k], there A[i]- the initial number of goblets near the i-th knight. Also X[i-K]+X[i]=F-A[i], and etc. Therefore you have to solve a system of linear equations, where each equation has two variables (others are zero). This can be optimised very well. If number of knights in the ring is odd, the solving is one. If it's even, you have to minimise it. The result is Sum(|X[i]|). Good luck to you all If you don't understand the solution you can mail me: vdshevch2@mail.ru I got AC! At first,My program got WA on #18, My bug is when N is even number,my answer is not minimum value 6 1 2 0 2 2 2 2 0 answer should be: 2 6 1 + 6 1 + I got WA test #21 many times before getting AC. I printed the result without noticing that the servant can take goblets from a knight only if he has at least one goblet near him. So you should print all '+' first and then '-'. 4 1 2 1 0 0 1 ans: 3 2 3 + 2 3 + 1 4 + 3 1 0 3 0 0 ans:-1 4 1 8 7 7 9 9 ans: 2 1 2 + 3 4 - 8 3 2 0 0 2 2 2 3 2 1 ans: 8 1 4 + 1 4 + 7 2 + 7 2 + 8 3 + 3 6 - 4 7 - 4 7 - 5 2 4 3 3 2 2 1 ans:-1 I remembmer clearly that when I solved it there were 74 accepts (I was 75-th). After that the number of AC grew to 90. And right now there is just 70 AC's. What happened? You are right. There were several bugs in the old validator in this problem. Because of them authors with incorrect solutions could get AC. I fixed the validator about 1 or 2 monthes ago. Tests were not changed. My prog WA test 3 please post this test or give me somr test!!! |
|
|