Submission #298220

#TimeUsernameProblemLanguageResultExecution timeMemory
298220shayan_pVision Program (IOI19_vision)C++17
59 / 100
11 ms1404 KiB
#include<bits/stdc++.h> #include "vision.h" #define F first #define S second #define PB push_back #define sz(s) (int(s.size())) #define bit(n, k) (((n)>>(k))&1) using namespace std; typedef long long ll; typedef pair<int, int> pii; const int LOG = 9; // kam tare! const int maxn = 210; int counter; int MAX_SUM; vector<int> operator + (vector<int> a, vector<int> b){ MAX_SUM++; vector<int> ans; int ext = -1; for(int i = 0; i < max(sz(a), sz(b)); i++){ vector<int> sm; if(ext != -1) sm.PB(ext); if(i < sz(a)) sm.PB(a[i]); if(i < sz(b)) sm.PB(b[i]); ans.PB(counter++); add_xor(sm); vector<int> toOr; for(int w = 0; w < sz(sm); w++) for(int w2 = w+1; w2 < sz(sm); w2++){ vector<int> chert = {sm[w], sm[w2]}; toOr.PB(counter++); add_and(chert); } if(toOr.empty()){ ext = -1; } else{ ext = counter++; add_or(toOr); } } if(ext != -1) ans.PB(ext); while((1<<(sz(ans)-1)) > MAX_SUM) ans.pop_back(); return ans; } int rows[maxn], cols[maxn]; void construct_network(int H, int W, int K){ auto to = [&](int x, int y){ return x * W + y; }; counter = H * W; for(int i = 0; i < H; i++){ vector<int> chert; for(int j = 0; j < W; j++) chert.PB(to(i, j)); rows[i] = counter++; add_xor(chert); } for(int j = 0; j < W; j++){ vector<int> chert; for(int i = 0; i < H; i++) chert.PB(to(i, j)); cols[j] = counter++; add_xor(chert); } vector<int> toSum; int Nw = -1; for(int i = 0; i < H; i++){ if(Nw == -1){ Nw = rows[i]; } else{ vector<int> chert = {Nw, rows[i]}; Nw = counter++; add_xor(chert); } toSum.PB(Nw); } Nw = -1; for(int j = 0; j < W; j++){ if(Nw == -1){ Nw = cols[j]; } else{ vector<int> chert = {Nw, cols[j]}; Nw = counter++; add_xor(chert); } toSum.PB(Nw); } vector<int> sum; for(int id : toSum){ vector<int> vec = {id}; sum = sum + vec; } bool bad = 0; for(int i = 0; i < LOG; i++){ if(bit(K, i)){ bad|= sz(sum) <= i; } else if(sz(sum) > i){ add_not(sum[i]); sum[i] = counter++; } } add_and(sum); counter++; if(bad){ add_not(0); counter++; vector<int> chert = {0, counter-1, counter-2}; add_and(chert); } }
#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...