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 "vision.h"
#include <bits/stdc++.h>
using namespace std;
/*
int h,w,k;
vector <int> t;
int current;
int calls=0;
void add_or(vector <int> v){
cout<<"Call No. "<<calls<<": requested or ";
for (auto&i:v) cout<<i<<' ';
cout<<endl;
calls++;
int n=v.size();
for (int i=0; i<n; i++){
if (v[i]<0||v[i]>=current){
cout<<"Invalid index provided on call adddd_or: "<<i<<"th element requested for "<<v[i];
exit(0);
}
}
int res=0;
for (int i=0; i<n; i++){
if (t[v[i]]==1){
res=1;
break;
}
}
t.push_back(res);
current++;
}
void add_xor(vector <int> v){
cout<<"Call No. "<<calls<<": requested xor ";
for (auto&i:v) cout<<i<<' ';
cout<<endl;
calls++;
int n=v.size();
for (int i=0; i<n; i++){
if (v[i]<0||v[i]>=current){
cout<<"Invalid index provided on call add_xor: "<<i<<"th element requested for "<<v[i];
exit(0);
}
}
int res=0;
for (int i=0; i<n; i++){
if (t[v[i]]==1){
res^=1;
}
}
t.push_back(res);
current++;
}
void add_and(vector <int> v){
cout<<"Call No. "<<calls<<": requested and ";
for (auto&i:v) cout<<i<<' ';
cout<<endl;
calls++;
int n=v.size();
if (n>10001){
cout<<"Too many instructions on call and_or\n";
exit(0);
}
for (int i=0; i<n; i++){
if (v[i]<0||v[i]>=current){
cout<<"Invalid index provided on call add_and: "<<i<<"th element requested for "<<v[i];
exit(0);
}
}
int res=1;
for (int i=0; i<n; i++){
if (t[v[i]]==0){
res=0;
break;
}
}
t.push_back(res);
current++;
}
void add_not(int v){
cout<<"Call No. "<<calls<<": requested not ";
cout<<v<<endl;
calls++;
if (v<0||v>=current){
cout<<"Invalid index provided on call and_not: "<<0<<"th element requested for "<<v;
exit(0);
}
int res=1;
if (t[v]==1){
res=0;
}
t.push_back(res);
current++;
}
*/
void construct_network(int H,int W,int K){
if (K==1){
for (int i=0; i<H; i++){
vector <int> v;
for (int j=0; j<W; j++) v.push_back(i*W+j);
add_or(v);
}
for (int j=0; j<W; j++){
vector <int> v;
for (int i=0; i<H; i++) v.push_back(i*W+j);
add_or(v);
}
for (int i=0; i<H-1; i++){
vector <int> v;
v.push_back(H*W+i);
v.push_back(H*W+i+1);
add_and(v);
}
for (int i=0; i<W-1; i++){
vector <int> v;
v.push_back(H*W+H+i);
v.push_back(H*W+H+i+1);
add_and(v);
}
vector <int> vv;
for (int i=0; i<H+W-2; i++) vv.push_back(H*W+H+W+i);
add_or(vv);
vector <int> ww;
for (int i=0; i<H+W; i++) ww.push_back(H*W+i);
add_xor(ww);
vector <int> xx;
xx.push_back(H*W+H+W+H+W-2);
xx.push_back(H*W+H+W+H+W-1);
add_and(xx);
return;
} else if (max(H,W)<=100||min(H,W)==1){
vector <int> initv1,initv2,initw;
int initnot;
for (int i=0; i<H; i++){
for (int j=0; j<W; j++){
vector <int> v;
for (int x=i,y=j-K; x!=i-K&&y!=j; x--,y++){
if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
}
for (int x=i-K,y=j; x!=i&&y!=j+K; x++,y++){
if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
}
for (int x=i,y=j+K; x!=i+K&&y!=j; x++,y--){
if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
}
for (int x=i+K,y=j; x!=i&&y!=j-K; x--,y--){
if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
}
if (v.empty()){
add_xor(initv1);
add_xor(initv2);
add_not(initnot);
add_and(initw);
continue;
}
add_xor(v);
if (!i&&!j){
initv1=v;
}
v.push_back(i*W+j);
add_xor(v);
add_not(H*W+4*(i*W+j)+1);
vector <int> w;
w.push_back(H*W+4*(i*W+j));
w.push_back(H*W+4*(i*W+j)+2);
add_and(w);
if (!i&&!j){
initv2=v;
initnot=H*W+4*(i*W+j)+1;
initw=w;
}
}
}
vector <int> f;
for (int i=0; i<H; i++){
for (int j=0; j<W; j++) f.push_back(H*W+4*(i*W+j)+3);
}
add_or(f);
return;
}
vector <int> v;
for (int x=K; x>=0; x--){
int y=K-x;
if (x>=0&&x<H&&y>=0&&y<W) v.push_back(x*W+y);
}
add_or(v);
return;
}
/*
int main(){
cin>>h>>w>>k;
for (int i=0; i<h*w; i++){
int v;
cin>>v;
t.push_back(v);
}
current=h*w;
construct_network(h,w,k);
for (auto&i:t) cout<<i<<' ';
cout<<endl;
}*/
Compilation message (stderr)
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:150:16: warning: 'initnot' may be used uninitialized in this function [-Wmaybe-uninitialized]
150 | add_not(initnot);
| ~~~~~~~^~~~~~~~~
# | 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... |