Common Boarddo you know why i got restricted function on test #5, i used math library for solve the problem, and i used fmod to get the answer You must use long arithmetics, because size of number N is more, than the sizes of standard types. On test #5 authors use very long number. NO! theres no need to use long arithmetics. This problem's mush more easier than waht you think.you can get AC in 0.001 I not used long arithmetics, but i have wrong answer on test 5 too. Was it Tuesday or Saturday??? Edited by author 23.10.2008 17:36 Well, there's a simple way to find that out, isn't there? Pseudocode here: begin For(i = mon, i<=sun; ++i) { Solve problem assuming 1 Jan 1600 was i; if(YourOutput==SampleOutput) break; } if(i>sun) you have solved the problem wrongly whatsoever; else it's very LIKELY that 1 JAN 1600 was i; end. But in order to save time, you can just believe me that 1 Jan 1600 was Saturday. At least assuming that my AC program works correctly:) All the best. A. We have some mismatch in english and russian versions of problem statements: 1.1. According to the “Defense” pattern, robot’s actions are defined as follows: calculate the number of enemies and multiply it by 20. If the result is __( greater )__ than the amount of ammunition units left, the robot will “Retreat and Return Fire”. Otherwise, it will act as if following the “Guard” pattern. 1.2. При реализации модели поведения «защита», робот действует так: если количество врагов умноженное на 20 __( не меньше )__ количества единиц вооружения робота, то робот отступает отстреливаясь. Иначе он действует согласно стратегии «охрана». 2.1. Similarly, when the battle-robot “Advances and Returns Fire”, it checks the angle to the most dangerous enemy. If the angle is 10 degrees or more, or there are no enemies, the robot just moves __( backward )__ or shoots otherwise. 2.2. «Наступает, отстреливаясь» означает, что если угол до самой опасной вражеской цели меньше 10, то робот делает выстрел. Иначе, или если врагов нет, движется __( вперед )__. 3.1. None of these integers exceeds __( 100000 )__. 3.2. Все числа, во входном файле целые и не превосходят __( 1000000 )__. ? What statement ( eng || rus ) should be consider as correct? I think, the English one. At least when I solved this problem, solution written on the basis of russian statement was getting WA because of (1.2) Will Admins correct russian statement? (or maybe english)? 1 and 2: the correct statement is the Russian one. We apologize to all programmers who solved this problem using the English statement. We added some tests that should have different answers according to the old English and Russian statements, so some authors got WA on them. Now the English statement should be OK. If you find more mistakes, please, write about them. 3: all integers in fact are no greater than 1000. This limitation has been updated in both Russian and English versions. Don't You forget to add this changes (and rejudges) to "Site News"? I was solving this problem during 5 days Next texts were helphfull 0 0.083334 4 30 2 60 330 4 60 90 8 60 60 10 60 ans 6.99999 1 2 4 3 0 0.1 3 0 2 60 0 3 70 0 6 80 ans 0.00000 1 2 3 0 0.083334 3 30 2 60 90 8 60 60 10 60 ans 2.9999 1 3 2 0 0.0833334 2 210 6 60 150 20 60 ans 6.9999 1 2 0 0.0833334 4 330 2 60 150 8 60 30 4 60 210 20 60 ans 8.99999 1 3 2 4 0 0.083334 2 90 10 60 330 10 60 ans: 4.999 2 1 Most of your tests are incorrect)) "All numbers contain at most three fractional digits". But they are surely useful. I can't say this problem is so hard. I had only some problems with accuracy. These tests may help: 0 0.010 3 359.999 167.667 100.000 180 84.334 100.000 0.001 1.001 100.000 ans 100.000 3 2 1 0 0.010 3 359.999 167.666 100.000 180 84.334 100.000 0.001 1.001 100.000 ans Impossible P. S. Can you give me some hints on 1672? Edited by author 12.02.2009 22:15 If you can't see this problem as easy all hints are unhelphull. We are, old mathematitians have habbit to use cost function, restrictions and sequence of points set under refimement procedure to find optimization result. var n,l,k1,i,k2 :longint; f :array[0..66666]of longint; k :array[0..66666,1..2]of longint; procedure qsort(a,b:longint); var i,j :longint; mid :array[1..2]of longint; begin i:=a;j:=b;mid:=k[i]; while i<j do begin while (k[j,1]>mid[1])and(j>i) do dec(j); if j>i then begin k[i]:=k[j]; inc(i); end; while (k[i,1]<mid[1])and(j>i) do inc(i); if j>i then begin k[j]:=k[i]; dec(j); end; end; k[i]:=mid; if i-1>a then qsort(a,i-1); if i+1<b then qsort(i+1,b); end; begin read(n); for i:=1 to n do begin read(k[i,1]); k[i,2]:=i; end; qsort(1,n); l:=1;k1:=1;k2:=0; fillchar(f,sizeof(f),0); while l<=n do begin k1:=k1+k2; inc(k2); while (k1>=k[l,1])and(l<=n) do if k1=k[l,1] then begin f[k[l,2]]:=1;inc(l);end else while (k1>k[l,1])and(l<=n)do inc(l); end; for i:=1 to n do if i=n then write(f[i]) else write(f[i],' '); end. In strings 11 and 27 you don`t write two index of array "k". var a,m,n:longint; d,o,w:double; begin readln(n,m); a:=0; w:=0; o:=0; repeat inc(a); d:=m/(a shl 1-1); if w+d>=n then break; w:=w+d; o:=o+m; until false; d:=n-w; o:=o+d*(a shl 1-1); writeln(round(o+0.49999999999)); end. I can't understand how can it take 1 sec to solve for N = 1000 My biggest ideas is something like a system of equations by modulo 2, but ... Some hints please... Please one small pour hint Please. I still have any ideas. May be finding of circles? linear module equations will work. try to rewrite it into a simpler form and you will achieve it! I found a lot of material about modular arithmetic itself, but nothing about systems of equations modulo 2. There is a problem 1042 that I solved using an intuitive algo. But I don't have any materials about those kind of problems... Any links in Internet are available. I haven't AC but sure that 1458 is a problem with great mathematical background. In matrix language Sulman command is equal to transformation of tipe A[j]*B*A[k] where A[j]=diag[1,1,1,...,-1,1,1,1,1..] So, read about minimal step of transformations to standard form. Also, sequence of such transformation is code for arbitrary 0-1 matrix. Sure that authors create the problem during reading about 0-1 matrix, transformations and coding. You're A LOOSER.I've done this program to 1 minute!!! Each has It's own way and all of us are training to contests. But even after you words the problem does't seem to me as simple. Often such quick solutions depend on temporary weakeness of tests. Ac after some period! I did'n beleve that O-1 equation method can help. We have 10^6 unknowns and O(10^18) Gauss. But I had expierence for large systems with itteration method(as for Puasson eqution) and this method works here. But after I understood that the matrix of the system is nilpotent because nature of smoothing operator and itteration method has right foundation. Edited by author 10.02.2009 09:24 Well, then, where is your AC for this problem? You have no AC's at all... Just find a way to flip some cell without affecting others. It's easy for even N. Edited by author 03.08.2008 11:31 Just find a way to flip some cell without affecting others. Thanks! At last got AC.. my algo is binary search on answer + dfs to check in my code I had such fragment: for (i = 0; i < n; i++) { g[i].clear(); color[i].clear(); u[i] = -1; } and got TLE then I changed clear() function to resize() for (i = 0; i < n; i++) { g[i].resize(0); color[i].resize(0); u[i] = -1; } and got AC in 0.2sec can anybody explain what happend? clear() works so slow??? I'm shocked as well!!! I don't know what place creators of STL wrote it through... Tbilisi SU: Giorgi, Akaki, [Andrew], thank you for this trick! I don't know what place creators of STL wrote it through... I think that 5x difference is because Timus compiler uses /O1 switch instead of usual /O2. In /O2 mode heap manager is very fast. I think it works much slower than 5x . because , number of edges in graph is not more than 10000 , binary search runs log(5000) ~ 12 times . for example if clear() needs O(n) time to clear vector , where n is number of elements in it, then total number of operations is 2*10000*12 = 240000, it seems that it runs 500 times slower... Edited by author 09.02.2009 14:25 What about such explanation? clear() frees memory, and the next time memory should be allocated again. resize() just changes internal pointer to the end of array nothing is freed and nothing is allocated then. Just many digits after decimal point. But here 8 digits gave me AC, but you may output, for example, 12-14. Edited by author 08.02.2009 16:51 Do you store the answer in double? Yes, tests for this problem are weak, so double is more than enough Thank you for information! I had WA on the contest, but now I'll try to solve this problem more accurate. Yes, during the contest I also thought the problem was in tricky tests. But after fixing minor bugs program got AC immediately... Test 3 contains equal values. Edited by author 08.02.2009 22:43 Edited by author 08.02.2009 19:50 Edited by author 08.02.2009 19:50 DP is easy. I want to know the easiest solution to the problem. Please contact me. megatronbiao@gmail.com Thanks. Sorry for my English. #include <iostream> #include <cmath> using namespace std; int data[60001]; int main() { int n; cin>>n; data[1]=1; data[2]=2; for (int i=3;i<=n;++i) { int min=data[i-1]+1; for (int j=2;j<=245;++j) { if (i>=j*j) { if (min>data[i-j*j]+1) min=data[i-j*j]+1; } else break; } data[i]=min; } cout<<data[n]; return 0; } What this test could be like? The Judge's Server is powerful.. i uses DFS and DP to kill it. But a simple wrong let me not 1Y this prolem.. Edited by author 07.02.2009 22:02 Wrong answer,why????? var a:array[1..100]of longint; c,n,m,i,l,k,b,o,p:longint; begin readln(n); if n=1 then begin read(k); write(k,' '); exit; end; c:=0;m:=0; for i:=1 to n do begin repeat inc(c);inc(m); read(k); a[m]:=k; until c=n; c:=0; end; if n=2 then begin write(a[1],' ',a[3],' ',a[2],' ',a[4],' '); exit; end; m:=1; for i:=1 to n do begin write(a[m],' '); b:=m; repeat if (b-n+1)>=(n-1) then write(a[b-n+1],' '); b:=b-n+1; until b<n-1; m:=m+n; end; c:=n*(n-1)+1;o:=0; for i:=n-1 downto 1 do begin inc(c); write(a[c],' '); l:=c;o:=i; if c=n*n then exit else repeat dec(o); if (c-n+1)>=(n-1) then write(a[c-n+1],' '); c:=c-n+1; until o=1; c:=l; end; end. I got CE. Please answer the question. In case you want to format the ouput, <iostream> will be just fine |
|