Submission #573888

#TimeUsernameProblemLanguageResultExecution timeMemory
573888StickfishVision Program (IOI19_vision)C++17
12 / 100
32 ms4436 KiB
#include "vision.h" #include <functional> #include <iostream> using namespace std; int memsz; struct cords { bool rvs; int h; int w; int get_num(int i, int j) const { if (rvs) j = w - j - 1; return i * w + j; } }; int get_downright(int h, int w, int k, cords cr) { vector<vector<int>> diags(w + h - 1); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { diags[i + j].push_back(cr.get_num(i, j)); } } vector<int> diag_nums; for (int i = 0; i < h + w - 1; ++i) { add_xor(diags[i]); diag_nums.push_back(memsz); ++memsz; } vector<int> diag_pairs; for (int i = 0; i + k < h + w - 1; ++i) { add_and({diag_nums[i], diag_nums[i + k]}); diag_pairs.push_back(memsz); ++memsz; } add_or(diag_pairs); int diag_check = memsz; ++memsz; //return diag_check; vector<vector<bool>> used(h, vector<bool>(w, false)); vector<int> direction_check; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (!used[i][j]) { vector<int> start; vector<int> end; for (int j0 = j; j0 < w; j0 += 2 * k) { for (int j1 = j0; j1 < j0 + k && j1 < w; ++j1) { start.push_back(cr.get_num(i, j1)); used[i][j1] = true; for (int i1 = i; i1 < h && i1 <= i + k; ++i1) { if (j1 + k - (i1 - i) < w) end.push_back(cr.get_num(i1, j1 + k - (i1 - i))); } } } if (start.empty() || end.empty()) continue; //for (auto x : start) //cout << x << ' '; //cout << "| "; //for (auto x : end) //cout << x << ' '; //cout << endl; add_xor(start); ++memsz; add_xor(end); ++memsz; add_and({memsz - 2, memsz - 1}); direction_check.push_back(memsz); ++memsz; } } } add_or(direction_check); ++memsz; add_and({memsz - 1, diag_check}); ++memsz; return memsz - 1; } void construct_network(int h, int w, int k) { int cnt = h * w; memsz = h * w; cords c; c.rvs = 0; c.h = h; c.w = w; int ans0 = get_downright(h, w, k, c); c.rvs = 1; int ans1 = get_downright(h, w, k, c); if (ans0 == -1) return; if (ans1 == -1) { add_and({ans0}); return; } add_or({ans0, ans1}); }

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:87:9: warning: unused variable 'cnt' [-Wunused-variable]
   87 |     int cnt = h * w;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...