| 
 | 
In python 3.6 extra print() in the end of the program gives you WA2. Therefore you should output "8  1 3 4 2 0 1 3 2" instead of "8  1 3 4 2 0 1 3 2  " Subj No, just bruteforce... >No, just bruteforce... A little optimized bruteforce gave me TLE in 'n' < ~20   There is a simple pattern in frogs moving. Paper simulation is so bored pastime - I had found out the pattern when wrote simple bruteforce for small 'n' cases. GL :) I found a pattern on the movemente... move first black frog Then: move  first & second white frog then: move first & second & third black frog keep doing this until the end   while doing that:    always start for the first frog that hasn't arrive to their final position    always end if you don't have anymore frogs to move   example with 2 and 3   8 1 3 4 2 0 1 3 2   15 2 4 5 3 1 0 2 4 6 5 3 1 2 4 3   Good luck   Edited by author 24.08.2014 16:33 Please, what is the input in test 1? I'm almost sure that I solved the problem right, but I still have WA1. It seems like the format of output doesn't work.. Maybe it's problem with output "-1". I counted that even for 499 it's not over one million - is that right? My solution use emulation with some heuristic conditions (for avoiding deadlock). Solution is o(n).   Some test: 1 output 3 0 2 1 -------- 2 output 8 1 3 4 2 0 1 3 2 -------- 3 output 15 2 4 5 3 1 0 2 4 6 5 3 1 2 4 3 -------- 4 output 24 3 5 6 4 2 1 3 5 7 8 6 4 2 0 1 3 5 7 6 4 2 3 5 4 -------- 5 output 35 4 6 7 5 3 2 4 6 8 9 7 5 3 1 0 2 4 6 8 10 9 7 5 3 1 2 4 6 8 7 5 3 4 6 5     Please tell me.     Thanks. "If there are many solutions, you may output any of them." i am on the 5th place of this problem ranking!!! (it's my record :)). if the sorting was also on the memory then i would be on 2nd place - and all of it i did at 5 o'clock, at night, on Pascal.  0.031 - 154kb 0.031 seconds 126 Kb 2nd place Is there more simple, mathematical way to solve this problem other than actually play the game with some smart heuristics (what I did in my solution)? yes, there is :) I used no array, just 4 variables n,t and legendary pair i,j ;) I used greedy approach. Prefer jumping to movement. Do not allow blockades. In case of tie keep empty space closer to border. I used simple brute-force =) #include <stdio.h>   int main(void) {   int n,m,i,p,d;   char f[999];   scanf("%d%d",&n,&m);   for(p=0;p<n;p++){     f[p]='W';     f[n+1+p]='B';   }   f[n]='_';   for(i=0;i<m;i++){     scanf("%d",&p);     if(p<0||2*n<p||f[p]=='_'){       printf("error: strange number (%d)\n",p);       return 1;     }     d=(f[p]=='W'?1:-1);     if(p+d<0||2*n<p+d){       printf("error: junp to out (%d->%d)\n",p,p+d);       return 1;     }     if(f[p+d]!='_')d*=2;     if(p+d<0||2*n<p+d||f[p+d]!='_'){       printf("error: jump to not empty (%d->%d)\n",p,p+d);       return 1;     }     f[p+d]=f[p];     f[p]='_';     // printf("%d->%d\n",p,p+d);   }   for(p=0;p<=2*n;p++)     putchar(f[p]);   putchar('\n');   return 0; }     Input   4 24 3 5 6 4 2 1 3 5 7 8 6 4 2 0 1 3 5 7 6 4 2 3 5 4   Output   BBBB_WWWW   Edited by author 22.08.2007 11:51 I've submitted the following solution, and it got AC:   #include <cstdio>   int main(void) {     int N;     scanf("%d", &N);     if (N==1)     {         printf("3\n2 0 1\n");     } else     {         printf("0\n");     }     return 0; }     Probably, this is a bug in checker What is the answear for N=2 && N=3? for 2:   21320124312   for 3 the answer is   245310246531243   Edited by author 06.10.2006 15:03   Edited by author 06.10.2006 15:03 Better answer for 2: 8 1 3 4 2 0 1 3 2  |  
  | 
|