#include <bits/stdc++.h>
using namespace std;
#ifndef WEEE
#include "vision.h"
#else
vector<int> qvr;
int add_not(int a) {
qvr.push_back(qvr[a] ^ 1);
return ((int)qvr.size() - 1);
}
int add_or (vector<int> a) {
int dr = 0;
for(int i : a) dr |= qvr[i];
qvr.push_back(dr);
return ((int)qvr.size() - 1);
}
int add_and(vector<int> a) {
int dr = 1;
for(int i : a) dr &= qvr[i];
qvr.push_back(dr);
return ((int)qvr.size() - 1);
}
int add_xor(vector<int> a) {
int dr = 0;
for(int i : a) dr ^= qvr[i];
qvr.push_back(dr);
return ((int)qvr.size() - 1);
}
#endif
int __w;
inline int I(int i, int j) {
return i * __w + j;
}
void add(int &x, int y) {
// nx = x + 17
int nx = add_xor({x, y});
add_and({x, y});
for(int i = 2; i < 17; i += 2) {
add_xor({nx + i - 1, x + i});
if(i ^ 16) add_and({nx + i - 1, x + i});
}
x = nx;
}
void construct_network(int h, int w, int k) {
k += 2;
__w = w;
///
for(int i = 0; i < h; ++i) {
vector<int> tv;
for(int j = 0; j < w; ++j) {
tv.push_back(I(i, j));
}
add_or(tv);
}
//
for(int j = 0; j < w; ++j) {
vector<int> tv;
for(int i = 0; i < h; ++i) {
tv.push_back(I(i, j));
}
add_or(tv);
}
/////
add_or({h * w});
for(int i = 1; i < h; ++i) {
add_or({(h + 1) * (w + 1) - 1 + i - 1, h * w + i});
}
//
add_or({h * w + h - 1});
for(int i = h - 2; i >= 0; --i) {
add_or({(h + 1) * (w + 1) + h - 2 + (h - 1 - i), h * w + i});
}
/////
add_or({h * (w + 1)});
for(int i = 1; i < w; ++i) {
add_or({h * (w + 1) + i, (h + 1) * (w + 1) + h - 1 + i});
}
//
add_or({h * (w + 1) + w - 1});
for(int i = w - 2; i >= 0; --i) {
add_or({h * (w + 1) + i, (h + 1) * (w + 1) + 2 * h + w - 2 + (w - 1 - i)});
}
/////
for(int i = 0; i < h; ++i) {
add_and({(h + 1) * (w + 1) - 1 + i, (h + 1) * (w + 1) + 2 * h - 2 - i});
}
//
for(int i = 0; i < w; ++i) {
add_and({(h + 1) * (w + 1) + 2 * h - 1 + i, (h + 1) * (w + 1) + 2 * h + 2 * w - 2 - i});
}
/////
int tr = h * w + 4 * h + 4 * w, fl = tr + 1;
assert(add_or({(h + 1) * (w + 1) + h - 2}) == tr);
add_not(tr);
/////
int jl = (h + 1) * (w + 1) + 2 * h + 2 * w - 1, jr = jl + w + h - 1, x = fl + 1;
for(int i = 0; i < 17; ++i) add_or({fl});
for(int i = jl; i <= jr; ++i) add(x, i);
/////
int y = x + 17;
for(int i = 0; i < 9; ++i) {
add_or({(k & (1 << i) ? tr : fl)});
if(i ^ 8) add_or({fl});
}
int z = y + 17;
for(int i = 0; i < 9; ++i) {
add_xor({x + 2 * i, y + 2 * i});
}
for(int i = 0; i < 9; ++i) {
add_not(z + i);
}
z = z + 9;
{
vector<int> tv;
for(int i = 0; i < 9; ++i) {
tv.push_back(z + i);
}
add_and(tv);
}
}
#ifdef WEEE
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
qvr = {1, 0, 0, 1};
construct_network(2, 2, 2);
cout << qvr.size() << endl;
for(int i = 0; i < qvr.size(); ++i) {
cout << qvr[i] << " ";
}
cout << endl;
cout << "[.] " << *(--qvr.end()) << endl;
return 0;
}
#endif
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
236 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 2), (1, 2), expected 1, but computed 0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
236 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 2), (1, 2), expected 1, but computed 0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
236 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 2), (1, 2), expected 1, but computed 0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
236 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 2), (1, 2), expected 1, but computed 0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
748 KB |
Output is correct |
2 |
Correct |
3 ms |
748 KB |
Output is correct |
3 |
Correct |
3 ms |
896 KB |
Output is correct |
4 |
Correct |
4 ms |
748 KB |
Output is correct |
5 |
Correct |
5 ms |
748 KB |
Output is correct |
6 |
Correct |
3 ms |
748 KB |
Output is correct |
7 |
Correct |
3 ms |
748 KB |
Output is correct |
8 |
Correct |
3 ms |
748 KB |
Output is correct |
9 |
Correct |
3 ms |
748 KB |
Output is correct |
10 |
Correct |
3 ms |
748 KB |
Output is correct |
11 |
Correct |
3 ms |
748 KB |
Output is correct |
12 |
Correct |
4 ms |
748 KB |
Output is correct |
13 |
Correct |
3 ms |
748 KB |
Output is correct |
14 |
Correct |
4 ms |
748 KB |
Output is correct |
15 |
Correct |
3 ms |
748 KB |
Output is correct |
16 |
Correct |
3 ms |
748 KB |
Output is correct |
17 |
Correct |
3 ms |
748 KB |
Output is correct |
18 |
Correct |
3 ms |
748 KB |
Output is correct |
19 |
Correct |
4 ms |
748 KB |
Output is correct |
20 |
Correct |
3 ms |
748 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
3 ms |
620 KB |
on inputs (0, 0), (0, 2), expected 0, but computed 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
1764 KB |
on inputs (80, 199), (81, 199), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
236 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
on inputs (0, 2), (1, 2), expected 1, but computed 0 |
8 |
Halted |
0 ms |
0 KB |
- |