|
|
back to boardTest-run program Posted by Sota 22 Aug 2007 11:48 #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 |
|
|