C. NEKO‘s Maze Game(路径判断)

https://codeforces.ml/contest/1293/problem/C 

 

有 2*n 的迷宫,有 m 个时间点,每一个时间点都会有一个地点从地面变成岩浆,或从岩浆变成地面,问能否从 (1,1) 走到 (2,n)

const int N=5e5+5;
 
    int n,m,t;
    int i,j,k;
    int a[3][N];

int main()
{
    //IOS;
    while(sdd(n,m)==2){
        int x,y,nx;
        int cnt=0;
        for(i=1;i<=m;i++){
            sdd(x,y);
            a[x][y]^=1;
            if(x==1) nx=2;
            else nx=1; 
            if(a[x][y]){
                if(a[nx][y]) cnt++;
                if(a[nx][y-1]) cnt++;
                if(a[nx][y+1]) cnt++;
            }
            else{
                if(a[nx][y]) cnt--;
                if(a[nx][y-1]) cnt--;
                if(a[nx][y+1]) cnt--;
            }
            //dbg(cnt);
            //dbg(a[2][n]);
            if(cnt || a[2][n]) puts("No");
            else puts("Yes");
        }
    }
    return 0;
    //PAUSE;
}

 

 

猜你喜欢

转载自blog.csdn.net/C_Dreamy/article/details/107802016