Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/rope>
  3.  
  4. using namespace std;
  5. using namespace __gnu_cxx;
  6.  
  7. random_device rd;
  8. mt19937 rnd(rd());
  9. #define pt pair<int, int>
  10. #define x first
  11. #define y second
  12. #define what_is(x) cerr << #x << " is " << x << endl;
  13. #define ok cerr << "ok" << endl;
  14. #define endl '\n'
  15. #define int long long
  16. #define ld long double
  17.  
  18. const int N = 1e5 + 5;
  19.  
  20. int a[2][N];
  21.  
  22. signed main()
  23. {
  24. cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
  25.  
  26. int n, q, cnt = 0;
  27. cin >> n >> q;
  28. while (q--)
  29. {
  30. int x, y;
  31. cin >> x >> y;
  32. --x, --y;
  33. if (a[x][y])
  34. {
  35. if (a[(x + 1) % 2][y]) --cnt;
  36. if (y > 0 && a[(x + 1) % 2][y - 1]) --cnt;
  37. if (y + 1 < n && a[(x + 1) % 2][y + 1]) --cnt;
  38. a[x][y] = 0;
  39. }
  40. else
  41. {
  42. if (a[(x + 1) % 2][y]) ++cnt;
  43. if (y > 0 && a[(x + 1) % 2][y - 1]) ++cnt;
  44. if (y + 1 < n && a[(x + 1) % 2][y + 1]) ++cnt;
  45. a[x][y] = 1;
  46. }
  47.  
  48. if (cnt)
  49. cout << "No" << endl;
  50. else
  51. cout << "Yes" << endl;
  52. }
  53.  
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement