#include "vision.h"
#include<iostream>
#define MAXN 205
using namespace std;
int p[4]={2,3,5,7}, P=4;
void construct_network(int H, int W, int K) {
int HasR[MAXN], HasC[MAXN], modR[10][10], modC[10][10], modDR[10][10], modDC[10][10];
vector<int> R[MAXN], C[MAXN], gR[10][10], gC[10][10];
int distR[MAXN], distC[MAXN], filler;
//generate whether each row and column has a black
for (int r=0; r<H; r++) {
for (int c=0; c<W; c++) {
R[r].push_back(r*W+c);
C[c].push_back(r*W+c);
}
}
for (int i=0; i<H; i++) {
HasR[i]=add_or(R[i]);
}
for (int i=0; i<W; i++) {
HasC[i]=add_or(C[i]);
}
vector <int> Dummy;
Dummy.push_back(HasC[0]);
Dummy.push_back(add_not(HasC[0]));
filler=add_and(Dummy); //guaranteed false
//generate position modulos
for (int i=0; i<P; i++) {
for (int r=0; r<H; r++) {
gR[i][r%p[i]].push_back(HasR[r]);
}
}
for (int i=0; i<P; i++) {
for (int c=0; c<W; c++) {
gC[i][c%p[i]].push_back(HasC[c]);
}
}
for (int i=0; i<P; i++) {
for (int mod=0; mod < p[i]; mod++) {
gR[i][mod].push_back(filler);
gC[i][mod].push_back(filler);
modR[i][mod]=add_or(gR[i][mod]);
modC[i][mod]=add_or(gC[i][mod]);
}
}
//generate dist modulos
for (int i=0; i<P; i++) {
vector<int> Rpos;
for (int mod=1; mod < p[i]; mod++) {
vector <int> ask;
for (int l=0; l<p[i]; l++) {
vector <int> Pair;
Pair.push_back(modR[i][l]);
Pair.push_back(modR[i][(l+mod)%p[i]]);
ask.push_back(add_and(Pair));
}
modDR[i][mod]=add_or(ask);
Rpos.push_back(modDR[i][mod]);
}
modDR[i][0]=add_not(add_or(Rpos));
}
for (int i=0; i<P; i++) {
vector<int> Cpos;
for (int mod=1; mod < p[i]; mod++) {
vector <int> ask;
for (int l=0; l<p[i]; l++) {
vector <int> Pair;
Pair.push_back(modC[i][l]);
Pair.push_back(modC[i][(l+mod)%p[i]]);
ask.push_back(add_and(Pair));
}
modDC[i][mod]=add_or(ask);
Cpos.push_back(modDC[i][mod]);
}
modDC[i][0]=add_not(add_or(Cpos));
}
//generate dists by CRT on dist modulos
vector<int> Rlist, Clist;
Rlist.push_back(filler);
Clist.push_back(filler);
for (int i=1; i<H; i++) {
vector<int> ask;
for (int j=0; j<P; j++) {
ask.push_back(modDR[j][i%p[j]]);
}
distR[i]=add_and(ask);
Rlist.push_back(distR[i]);
}
distR[0]=add_not(add_or(Rlist));
for (int i=1; i<W; i++) {
vector<int> ask;
for (int j=0; j<P; j++) {
ask.push_back(modDC[j][i%p[j]]);
}
distC[i]=add_and(ask);
Clist.push_back(distC[i]);
}
distC[0]=add_not(add_or(Clist));
//generate answer
vector <int> Res;
for (int i=0; i<=K; i++) {
vector <int> ask;
if (i < H && K-i < W) {
ask.push_back(distR[i]);
ask.push_back(distC[K-i]);
Res.push_back(add_and(ask));
}
}
add_or(Res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
0 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
1 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
1 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
248 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
0 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
1 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
1 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
248 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
504 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
0 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
1 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
1 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
248 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
504 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
28 |
Incorrect |
1 ms |
380 KB |
on inputs (20, 25), (27, 3), expected 0, but computed 1 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
0 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
1 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
1 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
248 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
504 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
28 |
Incorrect |
1 ms |
380 KB |
on inputs (20, 25), (27, 3), expected 0, but computed 1 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
on inputs (0, 0), (0, 29), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
4 ms |
632 KB |
Output is correct |
9 |
Correct |
4 ms |
632 KB |
Output is correct |
10 |
Incorrect |
4 ms |
632 KB |
on inputs (0, 0), (43, 134), expected 0, but computed 1 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1656 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
10 ms |
760 KB |
Output is correct |
5 |
Incorrect |
3 ms |
376 KB |
on inputs (0, 0), (0, 29), expected 0, but computed 1 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
0 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
1 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
1 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
248 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
504 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
28 |
Incorrect |
1 ms |
380 KB |
on inputs (20, 25), (27, 3), expected 0, but computed 1 |
29 |
Halted |
0 ms |
0 KB |
- |