# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
761176 | 2023-06-19T10:09:57 Z | raysh07 | Vision Program (IOI19_vision) | C++17 | 0 ms | 0 KB |
#include "vision.h" #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 1; int ac[N]; int pos; int cell(int i, int j, int m){ return i * m + j; } // int add_xor(vector <int> b){ // ac[pos] = 0; // for (auto x : b) ac[pos] ^= ac[x]; // return pos++; // } // int add_and(vector <int> b){ // ac[pos] = 1; // for (auto x : b) ac[pos] &= ac[x]; // return pos++; // } // int add_or(vector <int> b){ // ac[pos] = 0; // for (auto x : b) ac[pos] |= ac[x]; // return pos++; // } // int add_not(int b){ // ac[pos] = 1 - ac[b]; // return pos++; // } void construct_network(int n, int m, int k) { // std::vector<int> Ns; // Ns = {0, 1}; // int a = add_and(Ns); // Ns = {0, a}; // int b = add_or(Ns); // Ns = {0, 1, b}; // int c = add_xor(Ns); // add_not(c); vector <int> r; vector <int> a; for (int i = 0; i < n; i++){ a.clear(); for (int j = 0; j < m; j++) a.push_back(cell(i, j, m)); int x = add_xor(a); r.push_back(x); /// cout << i << " " << x << " " << ac[x] << "\n"; } a.clear(); for (auto &x : r){ a.push_back(x); x = add_xor(a); /// cout << x << " " << ac[x] << "\n"; } vector <int> c; for (int j = 0; j < m; j++){ a.clear(); for (int i = 0; i < n; i++) a.push_back(cell(i, j, m)); int x = add_xor(a); c.push_back(x); // cout << j << " " << x << " " << ac[x] << "\n"; } a.clear(); for (auto &x : c){ a.push_back(x); x = add_xor(a); } int v1 = add_or(r); v1 = add_not(v1); // cout << v1 << " " << ac[v1] << "\n"; int v2 = add_or(c); v2 = add_not(v2); // cout << v2 << " " << ac[v2] << "\n"; vector <int> r2, c2; for (int i = 1; i < r.size(); i++){ int x = add_and({r[i], r[i -1]}); r2.push_back(x); } int v3; if (r2.size()){ v3 = add_or(r2); v3 = add_not(v3); } else { v3 = -1; } // cout << v3 << " " << ac[v3] << "\n"; for (int i = 1; i < c.size(); i++){ int x = add_and({c[i], c[i - 1]}); c2.push_back(x); } int v4; if (c2.size()){ v4 = add_or(c2); v4 = add_not(v4); } else { v4 = -1; } // cout << v4 << " " << ac[v4] << "\n"; if (v4 != -1) int v5 = add_and({v1, v4}); if (v3 != -1) int v6 = add_and({v2, v3}); add_or({v5, v6}); } // int main(){ // int h, w, k; // cin >> h >> w >> k; // pos = h * w; // for (int i = 0; i < h * w; i++) cin >> ac[i]; // construct_network(h, w, k); // cout << ac[pos - 1] << "\n"; // return 0; // }