hiho week 57 register

Ended

Participants:308

Verdict:Accepted
Score:100 / 100
Submitted:2015-08-03 11:39:16

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cstdio>
inline bool yes(int x,int y)
{
    if(x<0||x>=5||y<0||y>=6) return false;
    return true;
}
int main()
{
    //freopen("in.txt","r",stdin);
    char t;
    int i,j,s=0,ts,op,top;
    for(i=0;i<5;i++)
        for(j=0;(t=getchar())!='\n';j++) if(t=='0')
            s|=1<<(i*6+j);
    for(op=0;op<64;op++){
        top=op;
        ts=s;
        for(i=0;i<6;i++) if((1<<i)&top){
            ts^=(1<<i);
            if(yes(0,i+1)) ts^=1<<(i+1);
            if(yes(0,i-1)) ts^=1<<(i-1);
            ts^=1<<(i+6);
        }
        for(i=1;i<5;i++)
            for(j=0;j<6;j++) if((1<<((i-1)*6+j))&ts){
                top|=1<<(i*6+j);
                ts^=1<<(i*6+j);
                if(yes(i+1,j)) ts^=1<<((i+1)*6+j);
                if(yes(i-1,j)) ts^=1<<((i-1)*6+j);
                if(yes(i,j+1)) ts^=1<<(i*6+j+1);
                if(yes(i,j-1)) ts^=1<<(i*6+j-1);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX