Submission #296413

#TimeUsernameProblemLanguageResultExecution timeMemory
296413SamAndVision Program (IOI19_vision)C++17
66 / 100
11 ms1152 KiB
#include "vision.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) typedef long long ll; const int N = 202; int n, m, k; void solv125() { vector<int> v; for (int x1 = 0; x1 < n; ++x1) { for (int y1_ = 0; y1_ < m; ++y1_) { for (int x2 = 0; x2 < n; ++x2) { for (int y2 = 0; y2 < m; ++y2) { if (abs(x1 - x2) + abs(y1_ - y2) == k) { if (m_p(x1, y1_) < m_p(x2, y2)) { v.push_back(add_and({x1 * m + y1_, x2 * m + y2})); } } } } } } add_or(v); } void solv6() { vector<int> v; for (int x1 = 0; x1 < 1; ++x1) { for (int y1_ = 0; y1_ < 1; ++y1_) { for (int x2 = 0; x2 < n; ++x2) { for (int y2 = 0; y2 < m; ++y2) { if (abs(x1 - x2) + abs(y1_ - y2) == k) { if (m_p(x1, y1_) < m_p(x2, y2)) { v.push_back(add_and({x1 * m + y1_, x2 * m + y2})); } } } } } } add_or(v); } void solv1237() { vector<int> t, s; for (int i = 0; i < n; ++i) { vector<int> v; for (int j = 0; j < m; ++j) { v.push_back(i * m + j); } t.push_back(add_or(v)); } for (int j = 0; j < m; ++j) { vector<int> v; for (int i = 0; i < n; ++i) { v.push_back(i * m + j); } s.push_back(add_or(v)); } vector<int> tt, ss; for (int d = 0; d < min(n, k + 1); ++d) { if (d == 0) { vector<int> v; for (int i = 0; i < n; ++i) v.push_back(t[i]); tt.push_back(add_xor(v)); continue; } vector<int> v; for (int i = 0; i + d < n; ++i) { v.push_back(add_and({t[i], t[i + d]})); } tt.push_back(add_or(v)); } for (int d = 0; d < min(m, k + 1); ++d) { if (d == 0) { vector<int> v; for (int i = 0; i < m; ++i) v.push_back(s[i]); ss.push_back(add_xor(v)); continue; } vector<int> v; for (int i = 0; i + d < m; ++i) { v.push_back(add_and({s[i], s[i + d]})); } ss.push_back(add_or(v)); } vector<int> v; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (i + j == k) { v.push_back(add_and({tt[i], ss[j]})); } } } add_or(v); } void construct_network(int H, int W, int K) { n = H; m = W; k = K; if (max(n, m) <= 10 || min(n, m) == 1) solv125(); else if (max(n, m) <= 30 || k == 1) solv1237(); else solv6(); }
#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...