#include <vision.h>
#include <vector>
using namespace std;
void construct_network(int H, int W, int K) {
vector<int> positions;
vector<int> positions2;
positions2.push_back(0);
positions2.push_back(0);
for (int i = 0; i < W; i++) {
positions.push_back(i);
}
for (int j = 0; j < H; j++) {
add_xor(positions);
for (int i = 0; i < W; i++) {
positions[i] += W;
}
}
positions.erase(positions.begin(), positions.end());
for (int i = 0; i < H; i++) {
positions.push_back(i*W);
}
for (int j = 0; j < W; j++) {
add_xor(positions);
for (int i = 0; i < H; i++) {
positions[i] += 1;
}
}
vector<int> positions_final_or;
#if 1
// H rows + W cols
// all pairs distance 1
// all pairs distance 2
// 1 pair distance H-1
int end_pos_x = H*W + H + W;
vector<int> positions_rows;
vector<int> positions_cols;
for (int j = 1; j < H; j++) {
positions_rows.push_back(end_pos_x);
for (int i = 0; i < H - j; i++) {
positions2[0] = H*W + i;
positions2[1] = H*W + j + i;
add_and(positions2);
++end_pos_x;
}
}
for (int j = 1; j < W; j++) {
positions_cols.push_back(end_pos_x);
for (int i = 0; i < W - j; i++) {
positions2[0] = H*W + H + i;
positions2[1] = H*W + H + i + j;
add_and(positions2);
++end_pos_x;
}
}
for (int j = 1; j < K; j++) {
// j in H, (K-j) in W
int options_y = H - j;
int options_x = W - (K - j);
vector<int> positions_and;
positions_and.push_back(0);
positions_and.push_back(0);
if ((options_y > 0) && (options_x > 0)) {
int position_y = positions_rows[j - 1];
int position_x = positions_cols[K - j - 1];
positions.erase(positions.begin(), positions.end());
for (int i = 0; i < options_y; i++) {
positions.push_back(position_y++);
}
positions_and.push_back(add_or(positions));
positions.erase(positions.begin(), positions.end());
for (int i = 0; i < options_x; i++) {
positions.push_back(position_x++);
}
positions_and.push_back(add_or(positions));
positions_final_or.push_back(add_and(positions_and));
}
}
#endif
positions2.push_back(0);
positions.erase(positions.begin(), positions.end());
for (int i = 0; i < W; i++) {
positions.push_back(H*W + H + i);
}
int pos1 = add_not(add_or(positions));
positions.erase(positions.begin(), positions.end());
for (int i = 0; i < H; i++) {
positions.push_back(H*W + i);
}
int pos2 = add_not(add_or(positions));
// 0-K and K-0
for (int j = 0; j < H - K; j++) {
positions2[0] = H*W + j;
positions2[1] = H*W + j + K;
positions2[2] = pos1;
positions_final_or.push_back(add_and(positions2));
}
for (int j = 0; j < W - K; j++) {
positions2[0] = H*W + H + j;
positions2[1] = H*W + H + j + K;
positions2[2] = pos2;
positions_final_or.push_back(add_and(positions2));
}
add_or(positions_final_or);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Incorrect |
5 ms |
384 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Incorrect |
5 ms |
384 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Incorrect |
5 ms |
384 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Incorrect |
5 ms |
384 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1148 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
436 KB |
Output is correct |
3 |
Correct |
8 ms |
892 KB |
Output is correct |
4 |
Correct |
9 ms |
892 KB |
Output is correct |
5 |
Correct |
9 ms |
768 KB |
Output is correct |
6 |
Correct |
9 ms |
768 KB |
Output is correct |
7 |
Correct |
8 ms |
768 KB |
Output is correct |
8 |
Incorrect |
6 ms |
1148 KB |
WA in grader: Too many instructions |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1532 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Incorrect |
5 ms |
384 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |