제출 #418009

#제출 시각아이디문제언어결과실행 시간메모리
418009SuhaibSawalha1Vision Program (IOI19_vision)C++17
58 / 100
1043 ms8364 KiB
#include "vision.h" #include <bits/stdc++.h> using namespace std; void construct_network(int n, int m, int k) { vector<int> OR; vector<int> row(n), col(m); int xor_for_rows, xor_for_cols; if (k == 1 || max(n, m) <= 100) { for (int i = 0; i < n; ++i) { vector<int> p; for (int j = 0; j < m; ++j) { p.push_back(i * m + j); } row[i] = add_or(p); } for (int j = 0; j < m; ++j) { vector<int> p; for (int i = 0; i < n; ++i) { p.push_back(i * m + j); } col[j] = add_or(p); } xor_for_rows = add_xor(row), xor_for_cols = add_xor(col); } if (max(n, m) <= 100) { vector<vector<int>> dist(n); vector<int> dist_or(n); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { dist[j - i].push_back(add_and({row[i], row[j]})); } } for (int i = 1; i < n; ++i) { dist_or[i] = add_or(dist[i]); } for (int i = 0; i < m; ++i) { for (int j = i + 1; j < m; ++j) { if (j - i == k) { OR.push_back(add_and({col[i], col[j], xor_for_rows})); } else if (j - i < k && k - j + i < n) { OR.push_back(add_and({col[i], col[j], dist_or[k - j + i]})); } } } if (k < n) { OR.push_back(add_and({dist_or[k], xor_for_cols})); } } else if (k == 1) { for (int i = 1; i < n; ++i) { OR.push_back(add_and({row[i - 1], row[i], xor_for_cols})); } for (int i = 1; i < m; ++i) { OR.push_back(add_and({col[i - 1], col[i], xor_for_rows})); } } else { int q = 1e4 - 1; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { vector<int> ask; for (int h = i; h < n; ++h) { for (int w = (i == h ? j : 0); w < m; ++w) { if (abs(i - h) + abs(j - w) == k && q > 1) { ask.push_back(h * m + w); } } } if (ask.size()) { q -= 2; OR.push_back(add_and({i * m + j, add_xor(ask)})); } } } } add_or(OR); }
#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...