First of all, say this OJ: it seems to be a University of 11 OJ ACM, called Aizu ONLINE JUDGE, it seems you can see some ben code ... Kneel down on your knees
And then know that this OJ is a game for Amway = =
Next you will do the following:
First of all, we can find that the number of two colors around each point is 2 ... (Don't ask me why)
It can then be found that the composition of the figure is composed of 2 * 2 of the same color tiles or a circle of the same color tiles and the length of each side is even, see the sample (Don't ask me why, because it is important so say two times)
It can then be found that if the state of the first row is determined, the entire solution is determined, and the state of the first row corresponds to the K one by one (don't ask me why, because it's important so say three times)
Then you can construct it directly ...
For a point (x, y), the color of the other three points around it (x, y-1) is determined, so it can also be determined
1#include <cstdio>2#include <cstring>3 4 using namespacestd;5typedefLong Longll;6 Const intN = -;7 Const intDx[] = {1, -1,0,0};8 Const intDy[] = {0,0,1, -1};9 Ten intN; One ll K; A intMp[n][n]; - -InlineBOOL out(intx) { the returnX <=0|| X >N; - } - - #defineX i + dx[k] + #defineY J + Dy[k] - intMain () { + intI, J, K, CNT; A while(SCANF ("%d%lld", &n, &K), n) { at--K; - if(K >= (1ll << (n/2)) || (N &1)) { -Puts"No"); -Putchar ('\ n'); - Continue; - } inMemset (MP,-1,sizeof(MP)); - for(i =1; I <= N; ++i) tomp[1][i] = (K >> (n-i >>1)) &1); + for(i =1; I < n; ++i) - for(j =1; J <= N; ++j) { the for(k = CNT =0; K <4; ++k) { * if( out(X) | | out(Y))Continue; $ if(Mp[x][y] = = Mp[i][j]) + +CNT;Panax Notoginseng } - if(CNT = =2) Mp[i +1][J] =!Mp[i][j]; the ElseMp[i +1][J] =Mp[i][j]; + } A for(i =1; I <= N; ++i) { the for(j =1; J <= N; ++j) +Putchar (Mp[i][j]?'E':'.'); -Putchar ('\ n'); $ } $Putchar ('\ n'); - } - return 0; the}
View Code
AOJ1024 Cleaning Robot 2.0