Advertisement
deushiro

Untitled

Jan 21st, 2020
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #include <algorithm>
  5. #include <map>
  6. #include <set>
  7.  
  8. using namespace std;
  9.  
  10. typedef long long ll;
  11.  
  12.  
  13. void solve() {
  14.     int n, q;
  15.     cin >> n >> q;
  16.     vector < vector<bool>> a(3, vector<bool>(n + 1));
  17.     int ans = 0;
  18.     for (int i = 0; i < q; ++i) {
  19.         int r, c;
  20.         cin >> r >> c;
  21.         --r;
  22.         int x = (a[r][c] ? -1 : 1);
  23.         a[r][c] = !a[r][c];
  24.         for (int i = -1; i <= 1; ++i) {
  25.             if (i + c <= 0 || i + c > n)
  26.                 continue;
  27.             if (a[(r + 1) % 2][i + c]) {
  28.                 ans += x;
  29.             }
  30.         }
  31.         cout << ((ans > 0) ? "No\n" : "Yes\n");
  32.  
  33.     }
  34. }
  35.  
  36.  
  37. int main()
  38. {
  39.     ios_base::sync_with_stdio(false);
  40.     cin.tie(0);
  41.     cout.tie(0);
  42.     solve();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement