fork download
  1. #include "Anna.h"
  2. #include <vector>
  3.  
  4. #include <bits/stdc++.h>
  5. #define MP make_pair
  6. #define PB push_back
  7. #define st first
  8. #define nd second
  9. #define rd third
  10. #define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
  11. #define RE(i, n) FOR(i, 1, n)
  12. #define FORD(i, a, b) for(int i = (a); i >= (b); --i)
  13. #define REP(i, n) for(int i = 0;i <(n); ++i)
  14. #define VAR(v, i) __typeof(i) v=(i)
  15. #define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
  16. #define ALL(x) (x).begin(), (x).end()
  17. #define SZ(x) ((int)(x).size())
  18. #define __builtin_ctz __builtin_ctzll
  19. #define __builtin_clz __builtin_clzll
  20. #define __builtin_popcount __builtin_popcountll
  21. using namespace std;
  22. template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
  23. template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  24. while(*sdbg != ',') { cerr<<*sdbg++; } cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
  25. }
  26. #ifdef LOCAL
  27. #define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
  28. #define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
  29. #else
  30. #define debug(...) (__VA_ARGS__)
  31. #define debugv(x)
  32. #define cerr if(0)cout
  33. #endif
  34. #define left ____left
  35. #define hash ____hash
  36. typedef long long ll;
  37. typedef long double LD;
  38. typedef pair<int, int> PII;
  39. typedef pair<ll, ll> PLL;
  40. typedef vector<int> VI;
  41. typedef vector<VI> VVI;
  42. typedef vector<ll> VLL;
  43. typedef vector<pair<int, int> > VPII;
  44. typedef vector<pair<ll, ll> > VPLL;
  45.  
  46. template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
  47. template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
  48. template<class T1, class T2>
  49. ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
  50. template<class A, class B, class C> struct Triple { A first; B second; C third;
  51. bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
  52. template<class T> void ResizeVec(T&, vector<int>) {}
  53. template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  54. vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  55. for (T& v : vec) { ResizeVec(v, sz); }
  56. }
  57. typedef Triple<int, int, int> TIII;
  58. template<class A, class B, class C>
  59. ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
  60. template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
  61. template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
  62. template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
  63.  
  64.  
  65. namespace {
  66.  
  67. int FunctionExample(int r, int c, int K) {
  68. return (r + c) % K + 1;
  69. }
  70. PII GetAnchor(PII A, PII B) {
  71. VPII vecs{{0, 1}, {1, -1}, {1, 0}, {1, 1}};
  72. for (auto v : vecs) {
  73. if ((A.st + v.st - B.st) % 3 == 0 && (A.nd + v.nd - B.nd) % 3 == 0) {
  74. return A;
  75. }
  76. }
  77. return B;
  78. }
  79. } // namespace
  80.  
  81. void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
  82. vector<vector<int>> rems(3, VI(3));
  83. REP (i, K) {
  84. rems[R[i] % 3][C[i] % 3] = 1;
  85. }
  86. VPII nons;
  87. REP (i, 3) {
  88. REP (j, 3) {
  89. if (rems[i][j] == 0) {
  90. nons.PB({i, j});
  91. }
  92. }
  93. }
  94. assert(SZ(nons) >= 2);
  95. nons.resize(2);
  96. if (GetAnchor(nons[0], nons[1]) != nons[0]) {
  97. swap(nons[0], nons[1]);
  98. }
  99. vector<VI> who(3, VI(3, -1));
  100. int nxt = 0;
  101. REP (i, 3) {
  102. REP (j, 3) {
  103. if (i == 0 && j == 0) { continue; }
  104. int ni = (nons[0].st + i) % 3;
  105. int nj = (nons[0].nd + j) % 3;
  106. PII p{ni, nj};
  107. if (p == nons[1]) { continue; }
  108. who[ni][nj] = nxt++;
  109. }
  110. }
  111. debug(who);
  112. for (int r = 0; r < N; r++) {
  113. for (int c = 0; c < N; c++) {
  114. if (r % 3 == nons[0].st && c % 3 == nons[0].nd) {
  115. SetFlag(r, c, 12);
  116. } else if (r % 3 == nons[1].st && c % 3 == nons[1].nd) {
  117. SetFlag(r, c, 12);
  118. // } else if (r % 3 == 0 && c % 3 == 1) {
  119. // int val = 8;
  120. // for (int i = 0; i < K; i++) {
  121. // if (R[i] == r && C[i] == c) {
  122. // val = i + 1;
  123. // }
  124. // }
  125. // SetFlag(r, c, val);
  126. // //SetFlag(r, c, 1);
  127. } else {
  128. int goal = who[r % 3][c % 3];
  129. int dr = R[goal] - r;
  130. int dc = C[goal] - c;
  131. if (dr >= 2) {
  132. SetFlag(r, c, 8);
  133. } else if (dr <= -2) {
  134. SetFlag(r, c, 9);
  135. } else if (dc >= 2) {
  136. SetFlag(r, c, 10);
  137. } else if (dc <= -2) {
  138. SetFlag(r, c, 11);
  139. } else {
  140. nxt = 1;
  141. FOR (di, -1, 1) {
  142. FOR (dj, -1, 1) {
  143. int nr = (r + di + 3) % 3;
  144. int nc = (c + dj + 3) % 3;
  145. int fail = 0;
  146. REP (tr, 2) {
  147. if (nr == nons[tr].st && nc == nons[tr].nd) {
  148. fail = 1;
  149. }
  150. }
  151. if (fail) {
  152. assert(di != dr || dj != dc);
  153. continue;
  154. }
  155. if (di == dr && dj == dc) {
  156. SetFlag(r, c, nxt);
  157. } else {
  158. nxt++;
  159. }
  160. }
  161. }
  162. //SetFlag(r, c, 1 + (dr + 1) + 3 * (dc + 1); // TODO
  163. }
  164. }
  165. }
  166. }
  167. }
  168.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:10: fatal error: Anna.h: No such file or directory
 #include "Anna.h"
          ^~~~~~~~
compilation terminated.
stdout
Standard output is empty