//{{{ #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I=(A);I<(B);I++) #define FORD(I,A,B) for(int I=(A);I>=(B);I--) #define REP(I,N) for(int I=0;I<(N);I++) #define VAR(V,init) __typeof(init) V=(init) #define FOREACH(I,C) for(VAR(I,(C).begin());I!=(C).end();I++) #define CLR(A,v) memset((A),v,sizeof((A))) #define ALL(X) (X).begin(), (X).end() #define PB push_back #define MP make_pair #define FI first #define SE second //}}} const int mxn=20; const int mxr=300; bool t[mxn][mxn]; int nm[mxn][mxn],n,m; char s[mxn]; bool mac[mxr][mxr]; int ilw,r; void dodaj(int x,int y){ FOR(p,0,n)FOR(k,0,m) mac[nm[k][p]][ilw]=( abs(x-k)+ abs(y-p )<=1 ); ++ilw; } void xoruj ( int a,int b) { FOR(p,0,r) mac[p][a]^=mac[p][b]; } void wypisz(){ FOR(p,0,r){ FOR(k,0,r) printf("%d ",mac[k][p]); printf("\n"); } printf("\n"); } void solve() { int a,ile=0,wyn=0,i; bool gut=true,g[mxr]; // wypisz(); FOR(p,0,r-1) { a=ile; while( (!mac[p][a]) && a=0;--a){ i=0; while(!mac[i][a])++i; FOR(p,0,a)if(mac[i][p])xoruj(p,a); } // wypisz(); FOR(p,0,r) if(mac[r-1][p]) ++wyn; FOR(p,0,r)g[p]=mac[r-1][p]; FOR(z,0,4){ a=0; if(z>=2){ ++a; FOR(p,0,r)g[p]^=mac[r-3][p]; } if(z%2==1){ ++a; FOR(p,0,r)g[p]^=mac[r-2][p]; } FOR(p,0,r-1)if(g[p])++a; if(a