#include <bits/stdc++.h>
#define forint(i, N) for (int i = 0; i < (N); i++)
using namespace std;
//vector<int> v = {1, 0, 0, 0, 1, 0};
vector<int> v = {0, 1, 0, 1, 0, 0};
int add_not(int N);
int add_and(vector<int> N);
int add_or(vector<int> N);
int add_xor(vector<int> N);
void construct_network(int h, int w, int k) {
vector<int> right;
int vsize = h * w - 1;
for (int i = h - 1; i >= 1; i--) {
int a = i;
int b = 0;
vector<int> tmp;
while (b < w && a < h) {
tmp.push_back(a * w + b);
a++;
b++;
}
vsize++;
right.push_back(vsize);
add_or(tmp);
}
for (int i = 0; i < w; i++) {
int a = 0;
int b = i;
vector<int> tmp;
while (b < w && a < h) {
tmp.push_back(a * w + b);
a++;
b++;
}
vsize++;
right.push_back(vsize);
add_or(tmp);
}
//cerr << vsize << " right diagonal" << endl;
//cerr << "ja" << endl;
vector<int> left;
for (int i = 0; i < h - 1; i++) {
int a = i;
int b = 0;
vector<int> tmp;
while (b < w && a >= 0) {
tmp.push_back(a * w + b);
a--;
b++;
}
vsize++;
left.push_back(vsize);
add_or(tmp);
}
for (int i = 0; i < w; i++) {
int a = h - 1;
int b = i;
vector<int> tmp;
while (b < w && a >= 0) {
tmp.push_back(a * w + b);
a--;
b++;
}
vsize++;
left.push_back(vsize);
add_or(tmp);
}
vector<int> right_test;
vector<int> left_test;
forint(i, right.size() - k) {
vsize++;
right_test.push_back(vsize);
add_and({right[i], right[i + k]});
vsize++;
left_test.push_back(vsize);
add_and({left[i], left[i + k]});
}
//cerr << "ja" << endl;
vector<int> right2;
vector<int> left2;
forint(i, right.size() - k) {
vector<int> tmp1;
vector<int> tmp2;
for (int j = i; j <= i + k; j++) {
tmp1.push_back(right[j]);
tmp2.push_back(left[j]);
}
//cerr << "ja " <<endl;
vsize += 2;
add_or(tmp1);
add_xor(tmp1);
add_xor({vsize - 1, vsize});
vsize++;
right2.push_back(vsize);
vsize += 2;
add_or(tmp2);
add_xor(tmp2);
add_xor({vsize - 1, vsize});
vsize++;
left2.push_back(vsize);
}
vsize++;
add_xor(right);
int a = vsize;
vsize++;
add_xor(left);
int b = vsize;
//cerr << "ja" << endl;
vsize++;
add_or(right2);
vsize++;
add_or(left2);
vsize++;
vsize++;
add_or({a, vsize - 2});
//cerr << v[vsize] << endl;
add_or({b, vsize - 2});
vsize++;
add_or(right_test);
//cerr << v[vsize] << endl;
vsize++;
add_or(left_test);
/*
for(auto a : left_test) {
cerr << v[a] << " ...\n";
}
cerr << v[vsize] << " OR " << v[v.size()-1] << endl;
*/
vsize++;
add_and({vsize - 4, vsize - 1});
add_and({vsize - 3, vsize - 2});
vsize++;
//cerr << v[vsize-1] << " OR " << v[vsize] << endl;
add_or({vsize - 1, vsize});
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:3:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
3 | #define forint(i, N) for (int i = 0; i < (N); i++)
| ^
vision.cpp:110:2: note: in expansion of macro 'forint'
110 | forint(i, right.size() - k) {
| ^~~~~~
vision.cpp:3:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
3 | #define forint(i, N) for (int i = 0; i < (N); i++)
| ^
vision.cpp:124:2: note: in expansion of macro 'forint'
124 | forint(i, right.size() - k) {
| ^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
420 KB |
Output is correct |
2 |
Correct |
7 ms |
588 KB |
Output is correct |
3 |
Correct |
5 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
5 ms |
676 KB |
Output is correct |
7 |
Correct |
5 ms |
552 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
3 ms |
360 KB |
Output is correct |
10 |
Correct |
5 ms |
588 KB |
Output is correct |
11 |
Correct |
5 ms |
588 KB |
Output is correct |
12 |
Correct |
5 ms |
672 KB |
Output is correct |
13 |
Correct |
6 ms |
588 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
3 ms |
460 KB |
Output is correct |
16 |
Correct |
5 ms |
588 KB |
Output is correct |
17 |
Correct |
5 ms |
652 KB |
Output is correct |
18 |
Correct |
5 ms |
716 KB |
Output is correct |
19 |
Correct |
4 ms |
588 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
460 KB |
Output is correct |
5 |
Correct |
3 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
460 KB |
Output is correct |
9 |
Correct |
5 ms |
676 KB |
Output is correct |
10 |
Correct |
6 ms |
716 KB |
Output is correct |
11 |
Correct |
5 ms |
588 KB |
Output is correct |
12 |
Correct |
4 ms |
548 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
5 ms |
668 KB |
Output is correct |
15 |
Correct |
5 ms |
588 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
6 ms |
676 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
7 ms |
844 KB |
Output is correct |
21 |
Correct |
15 ms |
1608 KB |
Output is correct |
22 |
Correct |
15 ms |
1532 KB |
Output is correct |
23 |
Correct |
5 ms |
716 KB |
Output is correct |
24 |
Correct |
7 ms |
844 KB |
Output is correct |
25 |
Correct |
16 ms |
1612 KB |
Output is correct |
26 |
Correct |
5 ms |
716 KB |
Output is correct |
27 |
Correct |
12 ms |
1376 KB |
Output is correct |
28 |
Correct |
24 ms |
2508 KB |
Output is correct |
29 |
Correct |
28 ms |
2756 KB |
Output is correct |
30 |
Correct |
24 ms |
2300 KB |
Output is correct |
31 |
Correct |
13 ms |
1124 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
1316 KB |
on inputs (96, 130), (143, 84), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |