#include <vector>
#include "vision.h"
using namespace std;
void construct_network(int H, int W, int K) {
if(K==H+W-2) {
add_or({add_and({0,H*W-1}),add_and({W-1,(W-1)*H})});
return;
}
vector<int> vdiag[H+W-1];
vector<int> vdiag2[H+W-1];
int idx_diag[H+W-1];
int idx_diag2[H+W-1];
for(int i=0; i<H; i++) {
for(int j=0; j<W; j++) {
vdiag[i+j].push_back(i*W+j);
vdiag2[H-1-i+j].push_back(i*W+j);
//cout << "vdiag: " << i*W+j << " " << i+j << " " << H-1-i+j << "\n";
}
}
for(int i=0; i<H+W-1; i++) {
idx_diag[i] = add_or(vdiag[i]);
}
for(int i=0; i<H+W-1; i++) {
idx_diag2[i] = add_or(vdiag2[i]);
}
vector<int> tmp;
for(int i=0; i+K<H+W-1; i++) {
tmp.push_back(add_and({idx_diag[i], idx_diag[i+K]}));
tmp.push_back(add_and({idx_diag2[i], idx_diag2[i+K]}));
}
vector<int> tmp2; // if any fail, we fail
vector<int> vtmp;
vector<int> vtmp2;
for(int i=H+W-2; i>K; i--) {
vtmp.push_back(idx_diag[i]);
vtmp2.push_back(idx_diag2[i]);
//cout << idx_diag[i] << "!!!\n";
}
for(int i=0; i+K<H+W-2; i++) {
/*cout << i << ": ";
for(int i: vtmp) {
cout << i << " ";
}
cout << "\n";*/
tmp2.push_back(add_and({idx_diag[i], add_or(vtmp)}));
tmp2.push_back(add_and({idx_diag2[i], add_or(vtmp2)}));
vtmp.pop_back();
vtmp2.pop_back();
}
//add_or(tmp);
add_and({add_or(tmp), add_not(add_or(tmp2))});
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
760 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
on inputs (0, 1), (0, 198), expected 0, but computed 1 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
7 ms |
888 KB |
Output is correct |
9 |
Correct |
6 ms |
764 KB |
Output is correct |
10 |
Correct |
4 ms |
632 KB |
Output is correct |
11 |
Correct |
3 ms |
632 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
760 KB |
Output is correct |
14 |
Correct |
4 ms |
632 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
7 ms |
760 KB |
Output is correct |
18 |
Correct |
4 ms |
424 KB |
Output is correct |
19 |
Incorrect |
2 ms |
252 KB |
on inputs (0, 0), (197, 0), expected 0, but computed 1 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
3448 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
7 ms |
888 KB |
Output is correct |
5 |
Correct |
6 ms |
760 KB |
Output is correct |
6 |
Correct |
7 ms |
760 KB |
Output is correct |
7 |
Correct |
16 ms |
2040 KB |
Output is correct |
8 |
Correct |
17 ms |
2040 KB |
Output is correct |
9 |
Correct |
30 ms |
3448 KB |
Output is correct |
10 |
Correct |
3 ms |
252 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |