This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "vision.h"
using namespace std;
vector<int> DT(int H,int W,int i,int K){
vector<int> ans;
for(int j=0;j<H*W;j++){
if(abs(j%W-i%W)+abs(j/W-i/W)==K){
ans.push_back(j);
}
}
return ans;
}
void construct_network(int H, int W, int K){
vector<int> b;
b.push_back(0);
b.push_back(1);
if(H*W>2)
b.push_back(2);
int l=add_and(b);
b.pop_back();
b.pop_back();
if(b.size())
b.pop_back();
b.push_back(l);
if(H*W==2){
if(K==1)
return;
else
l=add_not(0);
return;
}
if(min(H,W)==1){
for(int i=0;i<H*W-K;i++){
vector<int> ans;
ans.push_back(i);
ans.push_back(i+K);
l=add_and(ans);
ans.pop_back();
ans.pop_back();
ans.push_back(l-1);
ans.push_back(l);
l=add_or(ans);
}
return;
}
if(K==1){
int be,en;
be=l+1;
for(int i=0;i<H;i++){
vector<int> ans;
for(int j=0;j<W;j++){
ans.push_back(j+i*W);
}
en=add_or(ans);
}
int b,e;
b=en+1;
for(int i=0;i<W;i++){
vector<int> ans;
for(int j=i;j<W*H;j+=W){
ans.push_back(j);
}
e=add_or(ans);
}
int poss0H;
vector<int> rea;
for(int i=be;i<=en;i++){
rea.push_back(i);
}
poss0H=add_xor(rea);
int poss1H;
vector<int> jgf;
for(int i=be;i<en;i++){
vector<int> re;
re.push_back(i);
re.push_back(i+1);
jgf.push_back(add_and(re));
}
poss1H=add_or(jgf);
int poss0W;
vector<int> ria;
for(int i=b;i<=e;i++){
ria.push_back(i);
}
poss0W=add_xor(ria);
int poss1W;
vector<int> jf;
for(int i=b;i<e;i++){
vector<int> re;
re.push_back(i);
re.push_back(i+1);
jf.push_back(add_and(re));
}
poss1W=add_or(jf);
vector<int> nb;
nb.push_back(poss0W);
nb.push_back(poss1H);
e=add_and(nb);
nb[0]=poss1W;
nb[1]=poss0H;
b=add_and(nb);
nb[0]=e;
nb[1]=b;
en=add_or(nb);
return;
}
if(max(H,W)<=100){
vector<int> hd;
for(int i=0;i<H*W-K;i++){
vector<int> ans;
int h=(int)(DT(H,W,i,K).size()!=0);
if(h){
l=add_or(DT(H,W,i,K));
ans.push_back(l);
ans.push_back(i);
l=add_and(ans);
hd.push_back(l);
}
}
int f=add_or(hd);
return;
}
if(max(H,W)<=100){
}
else{
vector<int> ans;
for(int i=1;i<H*W;i++){
if((i%W)+(i/W)==K){
ans.push_back(i);
}
}
l=add_or(ans);
return;
}
}
Compilation message (stderr)
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:120:13: warning: unused variable 'f' [-Wunused-variable]
120 | int f=add_or(hd);
| ^
vision.cpp:88:22: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
88 | for(int i=b;i<e;i++){
| ~^~
vision.cpp:73:23: warning: 'en' may be used uninitialized in this function [-Wmaybe-uninitialized]
73 | for(int i=be;i<en;i++){
| ~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |