#include <bits/stdc++.h>
using namespace std;
#include "vision.h"
const int L = 9;
int zero;
vector<int> dist(vector<int> cells) {
int n = cells.size();
vector<int> split(n - 1);
for (int i = 0; i < n - 1; ++i) {
vector<int> l, r;
for (int j = 0; j < n; ++j) {
(j <= i ? l : r).push_back(j);
}
split[i] = add_and({add_or(l), add_or(r)});
}
vector<int> l(L, zero);
for (int i = 0; i < L; ++i) {
vector<int> ones, bools;
for (int j = 0; j < n - 1; ++j) {
if ((j & (1 << i)) > 0) {
ones.push_back(j);
}
if (!ones.empty()) {
bools.push_back(add_and({add_or(ones), split[j]}));
}
}
if (!bools.empty()) {
l[i] = add_or(bools);
}
}
vector<int> r(L, zero);
for (int i = 0; i < L; ++i) {
vector<int> ones, bools;
for (int j = n - 1; j > 0; --j) {
if ((j & (1 << i)) > 0) {
ones.push_back(j);
}
if (!ones.empty()) {
bools.push_back(add_and({add_or(ones), split[j - 1]}));
}
}
if (!bools.empty()) {
r[i] = add_or(bools);
}
}
vector<int> diff(L);
int carry = zero;
for (int i = 0; i < L; ++i) {
diff[i] = add_xor({l[i], r[i], carry});
carry = add_or({add_and({l[i], r[i], carry}), add_and({add_not(r[i]), add_or({l[i], carry})})});
}
return diff;
}
void construct_network(int h, int w, int k) {
zero = add_and({0, add_not(0)});
vector<int> rows(h);
for (int i = 0; i < h; ++i) {
vector<int> row;
for (int j = 0; j < w; ++j) {
row.push_back(i * w + j);
}
rows[i] = add_and(row);
}
vector<int> cols(w);
for (int i = 0; i < w; ++i) {
vector<int> col;
for (int j = 0; j < h; ++j) {
col.push_back(j * w + i);
}
cols[i] = add_and(col);
}
vector<int> r = dist(rows), c = dist(cols), sum;
int carry = zero;
for (int i = 0; i < L; ++i) {
sum[i] = add_xor({r[i], c[i], carry});
carry = add_or({add_and({r[i], c[i]}), add_and({r[i], carry}), add_and({c[i], carry})});
}
for (int i = 0; i < L; ++i) {
if ((k & (1 << i)) == 0) {
sum[i] = add_not(sum[i]);
}
}
add_and(sum);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
2632 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
2248 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |