#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
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});
}
/*if(m>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<m-1;j++){
add_and(cur5[j],cur5[j+1]);
cur6.pb(pos);
pos++;
}
add_or(cur6);
a2=pos;
pos++;
}*/
//52 points
/*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);*/
}
//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 |
1 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 |
1 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 |
1 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 |
1 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 |
9 ms |
896 KB |
Output is correct |
2 |
Incorrect |
9 ms |
896 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 |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 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 |
25 ms |
2432 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
640 KB |
Output is correct |
4 |
Correct |
6 ms |
776 KB |
Output is correct |
5 |
Correct |
9 ms |
896 KB |
Output is correct |
6 |
Incorrect |
1 ms |
640 KB |
WA in grader: Invalid index |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
- |