Submission #716852

#TimeUsernameProblemLanguageResultExecution timeMemory
716852NonozeVision Program (IOI19_vision)C++14
8 / 100
1 ms212 KiB
#include "vision.h" #include <bits/stdc++.h> using namespace std; void construct_network(int H, int W, int K) { vector<int> Ns; int empl=H*W-1; if (H>30 || W>30) { int i=0, j=0; vector<int> possibles; int act=i*W+j; for (int k = 0; k < H; ++k) { for (int l = 0; l < W; ++l) { if (abs(k-i)+abs(l-j)==K && k*W+l>=act) { possibles.push_back(k*W+l); } } } if (!possibles.size()) { return; } if (possibles.size()==1) { add_and({possibles[0], i*W+j}); empl++; } else { add_xor(possibles); empl++; add_and({empl, i*W+j}); empl++; } return; } if (K==1) { int l=0, r=H*W-1; while(l<r) { int mid=(l+r)/2; vector<int> temp; for (int i = l; i <= mid; ++i) { temp.push_back(i); } if (add_or(temp)) { r=mid; } else { l=mid+1; } } int act=l; vector<int> solution; int gd=act%W; if (act-W>=0) solution.push_back(act-W); if (act+W<=H*W-1) solution.push_back(act+W); if (gd-1>=0) solution.push_back(act-1); if (gd+1<=W) solution.push_back(act+1); add_or(solution); return; } for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { vector<int> possibles; int act=i*W+j; for (int k = 0; k < H; ++k) { for (int l = 0; l < W; ++l) { if (abs(k-i)+abs(l-j)==K && k*W+l>=act) { possibles.push_back(k*W+l); } } } if (!possibles.size()) continue; if (possibles.size()==1) { add_and({possibles[0], i*W+j}); empl++; } else { add_xor(possibles); empl++; add_and({empl, i*W+j}); empl++; } Ns.push_back(empl); } } add_or(Ns); return; }
#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...