#include <bits/stdc++.h>
#include "vision.h"
using namespace std;
void construct_network(int H, int W, int K) {
vector<int> row;
vector<int> col;
for (int i = 0; i < H * W; i++) col.push_back(i % W), row.push_back(i / W);
vector<vector<int>> maindiag(H + W - 1);
for (int i = 0; i < H * W; i++) maindiag[col[i] + row[i]].push_back(i);
int sz = H * W;
for (int i = 0; i < H + W - 1; i++) {
add_or(maindiag[i]);
sz++;
}
int start = sz;
for (int i = 0; i < H + W - 1 - K; i++) {
vector<int> inp;
inp.push_back(H * W + i);
inp.push_back(H * W + i + K);
add_and(inp);
sz++;
}
vector<int> maink;
for (int i = start; i < start + H + W - 1 - K; i++) maink.push_back(i);
add_or(maink);
int KFIRST = sz;
sz++;
vector<int> morek;
for (int i = 0; i < H + W - 1 - K - 1; i++) {
vector<int> inp1;
for (int j = i + K + 1; j < H + W - 1; j++) inp1.push_back(H * W + j);
add_or(inp1);
sz++;
vector<int> inp2;
inp2.push_back(H * W + i);
inp2.push_back(sz - 1);
add_and(inp2);
morek.push_back(sz);
sz++;
}
add_or(morek);
add_not(sz);
sz++;
int LKFIRST = sz;
sz++;
vector<vector<int>> otherdiag(H + W - 1);
for (int i = 0; i < H * W; i++) otherdiag[W - 1 - col[i] + row[i]].push_back(i);
int start2 = sz;
for (int i = 0; i < H + W - 1; i++) {
add_or(otherdiag[i]);
sz++;
}
start = sz;
for (int i = 0; i < H + W - 1 - K; i++) {
vector<int> inp;
inp.push_back(start2 + i);
inp.push_back(start2 + i + K);
add_and(inp);
sz++;
}
vector<int> otherk;
for (int i = start; i < start + H + W - 1 - K; i++) otherk.push_back(i);
add_or(otherk);
int KSECOND = sz;
sz++;
vector<int> moreok;
for (int i = 0; i < H + W - 1 - K - 1; i++) {
vector<int> inp1;
for (int j = i + K + 1; j < H + W - 1; j++) inp1.push_back(start2 + j);
add_or(inp1);
sz++;
vector<int> inp2;
inp2.push_back(start2 + i);
inp2.push_back(sz - 1);
add_and(inp2);
moreok.push_back(sz);
sz++;
}
add_or(moreok);
add_not(sz);
sz++;
int LKSECOND = sz;
sz++;
add_and({KFIRST, LKSECOND});
add_and({LKFIRST, KSECOND});
add_or({sz, sz + 1});
sz += 3;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
860 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
436 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
WA in grader: Instruction with no inputs |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
436 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
3480 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
720 KB |
Output is correct |
4 |
Correct |
3 ms |
860 KB |
Output is correct |
5 |
Correct |
3 ms |
860 KB |
Output is correct |
6 |
Correct |
5 ms |
752 KB |
Output is correct |
7 |
Correct |
9 ms |
2060 KB |
Output is correct |
8 |
Correct |
8 ms |
2060 KB |
Output is correct |
9 |
Correct |
15 ms |
3496 KB |
Output is correct |
10 |
Incorrect |
1 ms |
348 KB |
WA in grader: Instruction with no inputs |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |