#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;
// starting from W*H + H + W, put xor of all positions
positions.erase(positions.begin(), positions.end());
// last one is always 0
// indeces from H*W+H+W to H*W+H+W+H
for (int i = 0; i < H; i++) {
positions.push_back(W*H + i);
add_xor(positions);
}
positions.erase(positions.begin(), positions.end());
for (int i = 0; i < W; i++) {
positions.push_back(W*H + H + i);
add_xor(positions);
}
// we now have H+W bits, which we need to sum and compare to K
// H+W < 400 => 9 bits are enough for the sum
int pos = H*W + H + W;
// lets create 0 and 1 first
int zero_pos = W*H + H + W + H - 1;
positions.erase(positions.begin(), positions.end());
positions.push_back(zero_pos);
int one_pos = add_not(zero_pos);
int tmp = H + W - 2;
int num_bits = 0;
while (tmp > 0) {
++num_bits;
tmp >>= 1;
}
// set initial counter to 0
for (int i = 0; i < 3*num_bits; i++) {
add_not(one_pos);
}
int counter_pos = one_pos + 1;
for (int i = 0; i < H + W; i++) {
int carry_pos = zero_pos;
// adding next elements
for (int j = 0; j < num_bits; j++) {
vector<int> res(3);
res[0] = counter_pos + j * 3;
res[1] = pos + i;
res[2] = carry_pos;
add_xor(res);
vector<int> carry(2);
carry[0] = counter_pos + j * 3;
carry[1] = pos + i;
carry[0] = add_and(carry);
carry[1] = carry_pos;
carry_pos = add_or(carry);
}
counter_pos = counter_pos + num_bits * 3;
}
// compare counter to K
vector<int> final_and;
vector<int> bits(2);
for (int j = 0; j < num_bits; j++) {
bits[0] = (K & 1) ? one_pos : zero_pos;
bits[1] = counter_pos + j * 3;
final_and.push_back(add_xor(bits));
K >>= 1;
}
add_not(add_or(final_and));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 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 |
4 ms |
256 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 |
4 ms |
256 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 |
4 ms |
256 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 |
10 ms |
1008 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 |
5 ms |
256 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 |
6 ms |
1524 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |