Advertisement
pdpd123

Problem 13

Feb 17th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include<cstdlib>
  2. #include<cstdio>
  3. #include<cstring>
  4. int map[3][100005];
  5. int main()
  6. {
  7.     int n,q,s=0,r,c,f;
  8.     memset(map,0,sizeof(map));
  9.     scanf("%d %d",&n,&q);
  10.     map[1][1]=2;
  11.     map[2][n]=2;
  12.     while(q--)
  13.     {
  14.         scanf("%d %d",&r,&c);
  15.         f=(r==1?2:1);
  16.         if(map[r][c])
  17.         {
  18.             if(c>1&&map[f][c-1]==1)
  19.                 s--;
  20.             if(map[f][c]==1)
  21.                 s--;
  22.             if(c<n&&map[f][c+1]==1)
  23.                 s--;
  24.         }
  25.         else
  26.         {
  27.             if(c>1&&map[f][c-1]==1)
  28.                 s++;
  29.             if(map[f][c]==1)
  30.                 s++;
  31.             if(c<n&&map[f][c+1]==1)
  32.                 s++;
  33.         }
  34.         map[r][c]=!map[r][c];
  35.         if(s)
  36.             printf("No\n");
  37.         else
  38.             printf("Yes\n");
  39.     }
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement