# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1197206 | cpdreamer | Vision Program (IOI19_vision) | C++20 | 0 ms | 0 KiB |
#include<vision.h>
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define pb push_back
int h,w;
int cell(int i,int j){
return w*i+j;
}
int instruct(int i) {
return h*w-1+i;
}
bool valid(int i,int j) {
if (i<0 || i>=h || j<0 || j>=w)return false;
return true;
}
V<int>v={-1,1};
void construct_network(int H, int W, int K) {
h=H,w=W;
bool found=false;
for (int i=0;i<h;i++) {
V<int>vp;
for (int j=0;j<w;j++) {
vp.pb(cell(i,j));
}
int c=add_or(vp);
if (c) {
for (int j=0;j<w;j++) {
c=add_and({cell(i,j)});
if (c) {
for (auto u:v) {
if (valid(i+u,j)) {
c=add_and({cell(i+u,j)});
if (c) {
found=true;
break;
}
}
if (valid(i,j+u)) {
c=add_and({cell(i+u,j)});
if (c) {
found=true;
break;
}
}
}
break;
}
}
break;
}
}
if (found) {
add_or({1});
}
else
add_or({0});
}