#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
int dist (array<int, 2> a, array<int, 2> b) {
return abs(a[0] - b[0]) + abs(a[1] - b[1]);
}
void construct_network(int n, int m, int k) {
auto val = [&] (int i, int j) {
return i * m + j;
};
vector<int> OR;
int cur = n * m - 1;
if (k == 1) {
int row[n], col[m];
int xor_for_rows, xor_for_cols;
vector<int> ask_r, ask_c;
for (int i = 0; i < n; ++i) {
vector<int> p;
for (int j = 0; j < m; ++j) {
p.push_back(val(i, j));
}
add_xor(p);
row[i] = ++cur;
ask_r.push_back(cur);
}
for (int j = 0; j < m; ++j) {
vector<int> p;
for (int i = 0; i < n; ++i) {
p.push_back(val(i, j));
}
add_xor(p);
col[j] = ++cur;
ask_c.push_back(cur);
}
add_xor(ask_r);
xor_for_rows = ++cur;
add_xor(ask_c);
xor_for_cols = ++cur;
for (int i = 1; i < n; ++i) {
add_and({row[i - 1], row[i], xor_for_cols});
OR.push_back(++cur);
}
for (int i = 1; i < m; ++i) {
add_and({col[i - 1], col[i], xor_for_rows});
OR.push_back(++cur);
}
}
else {
int q = 1e4 - 1;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
vector<int> ask;
for (int h = i; h < n; ++h) {
for (int w = (i == h ? j : 0); w < m; ++w) {
if (dist({i, j}, {h, w}) == k && q) {
ask.push_back(val(h, w));
}
}
}
if (ask.size() && q > 2) {
ask.push_back(val(i, j));
add_xor(ask), ++cur;
add_not(cur), ++cur;
add_and({val(i, j), cur}); ++cur;
q -= 3;
OR.push_back(cur);
}
}
}
}
add_or(OR);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
1120 KB |
on inputs (80, 199), (81, 199), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |