제출 #521744

#제출 시각아이디문제언어결과실행 시간메모리
521744tabrVision Program (IOI19_vision)C++17
32 / 100
4 ms1356 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif #ifdef tabr function<int(int)> add_not; function<int(vector<int>)> add_and; function<int(vector<int>)> add_or; function<int(vector<int>)> add_xor; #else #include "vision.h" #endif void construct_network(int h, int w, int k) { vector<int> xs(h); for (int i = 0; i < h; i++) { vector<int> ask; for (int j = 0; j < w; j++) { ask.emplace_back(i * w + j); } xs[i] = add_or(ask); } vector<int> ys(w); for (int j = 0; j < w; j++) { vector<int> ask; for (int i = 0; i < h; i++) { ask.emplace_back(i * w + j); } ys[j] = add_or(ask); } vector<vector<int>> xt(h); xt[0].emplace_back(add_xor(xs)); for (int i = 0; i < h; i++) { for (int j = i + 1; j < h; j++) { xt[j - i].emplace_back(add_and({xs[i], xs[j]})); } } vector<vector<int>> yt(w); yt[0].emplace_back(add_xor(ys)); for (int i = 0; i < w; i++) { for (int j = i + 1; j < w; j++) { yt[j - i].emplace_back(add_and({ys[i], ys[j]})); } } vector<int> xu(h); for (int i = 0; i < h; i++) { xu[i] = add_or(xt[i]); } vector<int> yu(w); for (int i = 0; i < w; i++) { yu[i] = add_or(yt[i]); } vector<int> z; for (int i = 0; i < h; i++) { int j = k - i; if (j < 0 || w <= j) { continue; } z.emplace_back(add_and({xu[i], yu[j]})); } add_or(z); } #ifdef tabr int main() { ios::sync_with_stdio(false); cin.tie(0); for (int h = 1; h <= 3; h++) { for (int w = 1; w <= 3; w++) { for (int k = 1; k <= h + w - 2; k++) { for (int z1 = 0; z1 < h * w; z1++) { for (int z2 = z1 + 1; z2 < h * w; z2++) { int x1 = z1 / w; int y1 = z1 % w; int x2 = z2 / w; int y2 = z2 % w; vector<int> data(h * w); data[x1 * w + y1] = 1; data[x2 * w + y2] = 1; int cnt1 = 0; int cnt2 = 0; auto get = [&](int id) { assert(0 <= id && id < (int) data.size()); assert(cnt2++ < 1000000); return data[id]; }; auto add = [&](int v) { assert(cnt1++ < 1000000); data.emplace_back(v); }; add_not = [&](int n) { add(!get(n)); return (int) data.size() - 1; }; add_and = [&](vector<int> ns) { int res = 1; for (int n : ns) { res &= get(n); } add(res); return (int) data.size() - 1; }; add_or = [&](vector<int> ns) { int res = 0; for (int n : ns) { res |= get(n); } add(res); return (int) data.size() - 1; }; add_xor = [&](vector<int> ns) { int res = 0; for (int n : ns) { res ^= get(n); } add(res); return (int) data.size() - 1; }; construct_network(h, w, k); if (data.back() != (k == abs(x1 - x2) + abs(y1 - y2))) { cout << x1 << " " << x2 << " " << y1 << " " << y2 << '\n'; cout << data.back() << '\n'; cout << (k == abs(x1 - x2) + abs(y1 - y2)) << '\n'; } } } } } } return 0; } #endif
#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...