#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
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 |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
1 ms |
364 KB |
Output is correct |
28 |
Correct |
9 ms |
1004 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
3 ms |
492 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
9 ms |
1004 KB |
Output is correct |
35 |
Correct |
7 ms |
876 KB |
Output is correct |
36 |
Correct |
5 ms |
748 KB |
Output is correct |
37 |
Correct |
3 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
1 ms |
364 KB |
Output is correct |
28 |
Correct |
9 ms |
1004 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
3 ms |
492 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
9 ms |
1004 KB |
Output is correct |
35 |
Correct |
7 ms |
876 KB |
Output is correct |
36 |
Correct |
5 ms |
748 KB |
Output is correct |
37 |
Correct |
3 ms |
620 KB |
Output is correct |
38 |
Incorrect |
7 ms |
2660 KB |
WA in grader: Too many instructions |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
368 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
5 ms |
748 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
0 ms |
364 KB |
Output is correct |
24 |
Correct |
5 ms |
748 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
10 ms |
1132 KB |
Output is correct |
28 |
Correct |
1 ms |
364 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
0 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
33 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1132 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
5 ms |
748 KB |
Output is correct |
8 |
Correct |
5 ms |
748 KB |
Output is correct |
9 |
Correct |
10 ms |
1132 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
1 ms |
364 KB |
Output is correct |
28 |
Correct |
9 ms |
1004 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
3 ms |
492 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
9 ms |
1004 KB |
Output is correct |
35 |
Correct |
7 ms |
876 KB |
Output is correct |
36 |
Correct |
5 ms |
748 KB |
Output is correct |
37 |
Correct |
3 ms |
620 KB |
Output is correct |
38 |
Incorrect |
7 ms |
2660 KB |
WA in grader: Too many instructions |
39 |
Halted |
0 ms |
0 KB |
- |