#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;
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
292 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
524 KB |
Output is correct |
5 |
Correct |
5 ms |
476 KB |
Output is correct |
6 |
Correct |
3 ms |
476 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 |
504 KB |
Output is correct |
10 |
Incorrect |
4 ms |
624 KB |
on inputs (0, 0), (43, 134), expected 0, but computed 1 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
1628 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
608 KB |
Output is correct |
5 |
Incorrect |
3 ms |
376 KB |
WA in grader: Instruction with no inputs |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |