#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif
#ifdef tabr
function<int(int)> add_not;
function<int(vector<int>)> add_and;
function<int(vector<int>)> add_or;
function<int(vector<int>)> add_xor;
#else
#include "vision.h"
#endif
void construct_network(int h, int w, int k) {
vector<int> xs(h);
for (int i = 0; i < h; i++) {
vector<int> ask;
for (int j = 0; j < w; j++) {
ask.emplace_back(i * w + j);
}
xs[i] = add_or(ask);
}
vector<int> ys(w);
for (int j = 0; j < w; j++) {
vector<int> ask;
for (int i = 0; i < h; i++) {
ask.emplace_back(i * w + j);
}
ys[j] = add_or(ask);
}
vector<vector<int>> xt(h);
xt[0].emplace_back(add_xor(xs));
for (int i = 0; i < h; i++) {
for (int j = i + 1; j < h; j++) {
xt[j - i].emplace_back(add_and({xs[i], xs[j]}));
}
}
vector<vector<int>> yt(w);
yt[0].emplace_back(add_xor(ys));
for (int i = 0; i < w; i++) {
for (int j = i + 1; j < w; j++) {
yt[j - i].emplace_back(add_and({ys[i], ys[j]}));
}
}
vector<int> xu(h);
for (int i = 0; i < h; i++) {
xu[i] = add_or(xt[i]);
}
vector<int> yu(w);
for (int i = 0; i < w; i++) {
yu[i] = add_or(yt[i]);
}
vector<int> z;
for (int i = 0; i <= k; i++) {
int j = k - i;
if (j < 0 || w <= j) {
continue;
}
z.emplace_back(add_and({xu[i], yu[j]}));
}
add_or(z);
}
#ifdef tabr
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int h, w, k;
cin >> h >> w >> k;
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
vector<int> data(h * w);
data[x1 * w + y1] = 1;
data[x2 * w + y2] = 1;
int cnt1 = 0;
int cnt2 = 0;
auto get = [&](int id) {
assert(0 <= id && id < (int) data.size());
assert(cnt2++ < 1000000);
return data[id];
};
auto add = [&](int v) {
assert(cnt1++ < 1000000);
data.emplace_back(v);
};
add_not = [&](int n) {
add(!get(n));
return (int) data.size() - 1;
};
add_and = [&](vector<int> ns) {
int res = 1;
for (int n : ns) {
res &= get(n);
}
add(res);
return (int) data.size() - 1;
};
add_or = [&](vector<int> ns) {
int res = 0;
for (int n : ns) {
res |= get(n);
}
add(res);
return (int) data.size() - 1;
};
add_xor = [&](vector<int> ns) {
int res = 0;
for (int n : ns) {
res ^= get(n);
}
add(res);
return (int) data.size() - 1;
};
construct_network(h, w, k);
cout << data.back() << '\n';
cout << (k == abs(x1 - x2) + abs(y1 - y2)) << '\n';
return 0;
}
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
292 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
292 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
292 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
292 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1060 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
on inputs (0, 0), (1, 0), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1444 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
292 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |