#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
void construct_network(int H, int W, int K){
if(H*W == 2){
add_or({0, 1});
return;
}
int d = H+W-1, mhw = min(H, W);
int hw = add_and({0, 1, 2});
vector<int> d1v;
d1v.reserve(d);
for(int i=0; i<d; i++){
vector<int> cur;
for(int j=0; j<H; j++){
int ch = j, cw = i-j;
if(ch > -1 && ch < H && cw > -1 && cw < W){
cur.pb(cw + ch*W);
}
}
if(!cur.size()){
cerr << 'i' << i << '\n';
}
d1v.pb(add_or(cur));
}
vector<int> d2v;
d2v.reserve(d);
for(int i=0; i<d; i++){
vector<int> cur;
for(int j=0; j<H; j++){
int ch = j, cw = W-1-i+j;
if(ch > -1 && ch < H && cw > -1 && cw < W){
cur.pb(cw + ch*W);
}
}
if(!cur.size()){
cerr << 'i' << i << '\n';
}
d2v.pb(add_or(cur));
}
vector<int> k1v, k2v, j1v, j2v;
vector<int> pro;
for(int i=0; i<K; i++){
pro.pb(d1v[i]);
}
for(int j=K; j<d; j++){
pro.pb(d1v[j]);
k1v.pb(add_and({add_or(pro), add_not(add_xor(pro))}));
pro.erase(pro.begin());
}
pro.clear();
for(int i=0; i<K; i++){
pro.pb(d2v[i]);
}
for(int j=K; j<d; j++){
pro.pb(d2v[j]);
k2v.pb(add_and({add_or(pro), add_not(add_xor(pro))}));
pro.erase(pro.begin());
}
pro.clear();
for(int i=0; i<K-1; i++){
pro.pb(d1v[i]);
}
for(int j=K-1; j<d; j++){
pro.pb(d1v[j]);
j1v.pb(add_and({add_or(pro), add_not(add_xor(pro))}));
pro.erase(pro.begin());
}
pro.clear();
for(int i=0; i<K-1; i++){
pro.pb(d2v[i]);
}
for(int j=K-1; j<d; j++){
pro.pb(d2v[j]);
j2v.pb(add_and({add_or(pro), add_not(add_xor(pro))}));
pro.erase(pro.begin());
}
pro.clear();
int k1 = add_or(k1v), k2 = add_or(k2v), j1, j2;
if(K!=1){
j1 = add_or(j1v), j2 = add_or(j2v);
}
else{
j1 = hw, j2 = hw;
}
int nc = add_or({add_not(k1), add_not(k2)}), c1 = add_and({k1, add_not(j1)}), c2 = add_and({k2, add_not(j2)});
cerr << nc << ' ' << c1 << ' ' << c2 << '\n';
add_and({add_not(nc), add_or({c1, c2})});
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:12:17: warning: unused variable 'mhw' [-Wunused-variable]
12 | int d = H+W-1, mhw = min(H, W);
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
7 ms |
1176 KB |
Output is correct |
3 |
Correct |
9 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
7 ms |
1096 KB |
Output is correct |
7 |
Correct |
6 ms |
856 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
712 KB |
Output is correct |
10 |
Correct |
7 ms |
1116 KB |
Output is correct |
11 |
Correct |
7 ms |
1116 KB |
Output is correct |
12 |
Correct |
7 ms |
1116 KB |
Output is correct |
13 |
Correct |
5 ms |
856 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
6 ms |
932 KB |
Output is correct |
17 |
Correct |
7 ms |
1116 KB |
Output is correct |
18 |
Correct |
7 ms |
1116 KB |
Output is correct |
19 |
Correct |
7 ms |
860 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 0), (1, 1), expected 1, but computed 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1748 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
688 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
600 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
5 ms |
1240 KB |
Output is correct |
8 |
Correct |
5 ms |
1240 KB |
Output is correct |
9 |
Correct |
9 ms |
1584 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |