Submission #1071521

#TimeUsernameProblemLanguageResultExecution timeMemory
1071521Gromp15Vision Program (IOI19_vision)C++17
100 / 100
13 ms1788 KiB
#include "vision.h" #include <bits/stdc++.h> #define ll long long #define ar array #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() using namespace std; template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } void construct_network(int H, int W, int K) { vector<int> v; { vector<int> val(H), val2(H); for (int i = 0; i < H; i++) { vector<int> cur; for (int j = 0; j < W; j++) { cur.emplace_back(i*W+j); } val[i] = val2[i] = add_or(cur); } for (int i = 1; i < H; i++) val[i] = add_or({val[i], val[i-1]}); for (int i = H-2; i >= 0; i--) val2[i] = add_or({val2[i], val2[i+1]}); for (int i = 0; i < H; i++) v.emplace_back(add_and({val[i], val2[i]})); } { vector<int> val(W), val2(W); for (int j = 0; j < W; j++) { vector<int> cur; for (int i = 0; i < H; i++) { cur.emplace_back(i*W+j); } val[j] = val2[j] = add_or(cur); } for (int i = 1; i < W; i++) val[i] = add_or({val[i], val[i-1]}); for (int i = W-2; i >= 0; i--) val2[i] = add_or({val2[i], val2[i+1]}); for (int i = 0; i < W; i++) v.emplace_back(add_and({val[i], val2[i]})); } int Z = add_and({0, add_not(0)}), O = add_not({Z}); vector<int> val; for (int i = 0; i < 9; i++) val.push_back(add_or({Z})); int sum = 0; for (int x : v) { sum++; for (int j = 0; j < 9; j++) { if ((1 << j) > sum) break; int orig = val[j]; val[j] = add_xor({val[j], x}); x = add_and({x, orig}); } } vector<int> ans(9); for (int i = 0; i < 9; i++) { if ((K + 2) >> i & 1) ans[i] = add_or({O}); else ans[i] = add_or({Z}); } vector<int> ret; for (int i = 0; i < 9; i++) ret.push_back(add_xor({val[i], ans[i]})); add_not(add_or(ret)); }
#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...