#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#include "vision.h"
void construct_network(int n, int m, int k) {
//k=1
//52 points
if(n==1 or m==1){
vector<int> cur;
int pos=n*m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
vector<int> cur2;
for(int kk=0;kk<n;kk++){
for(int ll=0;ll<m;ll++){
if(abs(i-kk)+abs(j-ll)==k){
cur2.pb(kk*m+ll);
}
}
}
if(cur2.size()==0){
continue;
}
add_or(cur2);
add_and({pos,i*m+j});
cur.pb(pos+1);
pos+=2;
}
}
add_or(cur);
return ;
}
vector<int> cur;
vector<int> cur3;
int pos=n*m;
for(int i=0;i<n;i++){
vector<int> cot;
for(int j=0;j<m;j++){
cot.pb(i*m+j);
}
add_or(cot);
cur.pb(pos);
cur3.pb(pos);
pos++;
}
vector<int> cur2;
for(int j=0;j<m;j++){
vector<int> cot;
for(int i=0;i<n;i++){
cot.pb(i*m+j);
}
add_or(cot);
cur2.pb(pos);
cur3.pb(pos);
pos++;
}
int a1=pos;
pos++;
add_xor(cur3);
int a2=-1;
int a3=-1;
/* for(auto j:cur){
cout<<j<<";";
}
cout<<endl;*/
if(n>1){
vector<int> cur4;
vector<int> cur5;
for(auto j:cur){
cur4.pb(j);
add_xor(cur4);
cur5.pb(pos);
pos++;
}
vector<int> cur6;
for(int j=0;j<n-1;j++){
add_and({cur5[j],cur5[j+1]});
cur6.pb(pos);
pos++;
}
add_or(cur6);
int a4=pos;
// cout<<pos<<"/"<<endl;
pos++;
//if count=2 in that row a4 checks if they are consecutive
//compute if count==2
vector<int> cur7;
for(int i=0;i<n-1;i++){
vector<int> cur8;
vector<int> cur9;
for(int j=0;j<=i;j++){
cur8.pb(cur[j]);
}
for(int j=i+1;j<n;j++){
cur9.pb(cur[j]);
}
add_or(cur8);
add_or(cur9);
add_and({pos,pos+1});
pos+=2;
cur7.pb(pos);
pos++;
}
add_or(cur7);//uses pos,should be 0
//cout<<pos<<endl;
pos++;
add_not(a4);
// cout<<pos<<endl;
pos+=1;
add_and({pos-2,pos-1});//uses pos+1,should be 1
a2=pos;
pos+=1;
}
if(m>1){
vector<int> cur4;
vector<int> cur5;
for(auto j:cur2){
cur4.pb(j);
add_xor(cur4);
cur5.pb(pos);
pos++;
}
vector<int> cur6;
for(int j=0;j<m-1;j++){
add_and({cur5[j],cur5[j+1]});
cur6.pb(pos);
pos++;
}
add_or(cur6);
int a4=pos;
pos++;
//if count=2 in that row a4 checks if they are consecutive
//compute if count==2
vector<int> cur7;
for(int i=0;i<m-1;i++){
vector<int> cur8;
vector<int> cur9;
for(int j=0;j<=i;j++){
cur8.pb(cur2[j]);
}
for(int j=i+1;j<m;j++){
cur9.pb(cur2[j]);
}
add_or(cur8);
add_or(cur9);
add_and({pos,pos+1});
pos+=2;
cur7.pb(pos);
pos++;
}
add_or(cur7);//uses pos,should be 0
pos++;
add_not(a4);
pos+=1;
add_and({pos-1,pos-2});//uses pos+1,should be 1
a3=pos;
pos+=1;
}
// cout<<a1<<":"<<a2<<":"<<a3<<endl;
if(a2==-1){
add_and({a1,a3});
}
else if(a3==-1){
add_and({a2,a3});
}
else{
add_or({a2,a3});
add_and({a1,pos});
}
}
//g++ -o bb grader.cpp vision.cpp
/*
2 3 3
0 0 0 1
0 0 0 2
0 0 1 0
0 0 1 1
0 0 1 2
0 1 0 2
0 1 1 0
0 1 1 1
0 1 1 2
0 2 1 0
0 2 1 1
0 2 1 2
1 0 1 1
1 0 1 2
1 1 1 2
-1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Incorrect |
0 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Incorrect |
0 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Incorrect |
0 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Incorrect |
0 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
256 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
256 KB |
Output is correct |
21 |
Correct |
1 ms |
256 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
2432 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
7 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
14 ms |
1536 KB |
Output is correct |
8 |
Correct |
15 ms |
1536 KB |
Output is correct |
9 |
Correct |
29 ms |
2560 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Incorrect |
0 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
7 |
Halted |
0 ms |
0 KB |
- |