#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <cassert>
#include <tuple>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long LL;
typedef vector<int> Vi;
typedef vector<bool> Vb;
typedef vector<vector<int>> Vii;
#define forR(i, n) for (int i = 0; i < (n); i++)
int add_not(int N);
void Get_le_k(Vi& rs, Vi& d1r, int K, int& dd1_le_k);
int add_and(Vi Ns);
int add_or(Vi Ns);
int add_xor(Vi Ns);
int Get_le_k(const Vi& d1r, int K)
{
Vi rs;
for (int i = 0; i < d1r.size() - K; i++) {
Vi range; // [i, i+K]
for (int j = 0; j <= K; j++) {
range.push_back(i + j);
}
int or_range = add_or(range);
int xor_range = add_xor(range);
int not_xor_range = add_not(xor_range);
rs.push_back(add_and(Vi{ or_range,not_xor_range }));
}
int dd1_ge1_leK = add_or(rs);
int dd1_eq0 = add_not(add_or(d1r));
return add_or(Vi{ dd1_eq0, dd1_ge1_leK });
}
void construct_network(int H, int W, int K) {
// d1[i] x+y == i d2[i] x+(W-1-y) == i
Vii d1(H + W - 1), d2(H + W - 1);
forR(x, H) forR(y, W) {
int index = x * W + y;
int i1 = x + y, i2 = x + (W - 1 - y);
d1[i1].push_back(index); d2[i2].push_back(index);
}
Vi d1r, d2r;
for (auto& d1_line : d1) {
d1r.push_back(add_xor(d1_line));
}
for (auto& d2_line : d2) {
d2r.push_back(add_xor(d2_line));
}
int dd1_eq_k, dd1_le_k, dd2_eq_k, dd2_le_k;
// d1
{
Vi rs;
for (int i = 0; i < d1r.size() - K; i++) {
rs.push_back(add_and(Vi{ d1r[i], d1r[i + K] }));
}
dd1_eq_k = add_or(rs);
dd1_le_k = Get_le_k(d1r, K);
}
// d2
{
Vi rs;
for (int i = 0; i < d2r.size() - K; i++) {
rs.push_back(add_and(Vi{ d2r[i], d2r[i + K] }));
}
dd2_eq_k = add_or(rs);
dd2_le_k = Get_le_k(d2r, K);
}
int dd1_k = add_and(Vi{ dd1_eq_k, dd2_le_k });
int dd2_k = add_and(Vi{ dd2_eq_k, dd1_le_k });
add_or(Vi{ dd1_k, dd2_k });
return;
}
#ifdef TEST_LOCAL
int add_not(int N) { return -1; }
int add_and(Vi Ns) { return -1; }
int add_or(Vi Ns) { return -1; }
int add_xor(Vi Ns) { return -1; }
int main() {
construct_network(200, 200, 1);
return 0;
}
#endif
Compilation message
vision.cpp: In function 'int Get_le_k(const Vi&, int)':
vision.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i = 0; i < d1r.size() - K; i++) {
| ~~^~~~~~~~~~~~~~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:74:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | for (int i = 0; i < d1r.size() - K; i++) {
| ~~^~~~~~~~~~~~~~~~
vision.cpp:85:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | for (int i = 0; i < d2r.size() - K; i++) {
| ~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
460 KB |
Output is correct |
2 |
Correct |
6 ms |
588 KB |
Output is correct |
3 |
Correct |
6 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 |
592 KB |
Output is correct |
7 |
Correct |
5 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
2 ms |
460 KB |
Output is correct |
10 |
Correct |
5 ms |
588 KB |
Output is correct |
11 |
Correct |
6 ms |
716 KB |
Output is correct |
12 |
Correct |
7 ms |
716 KB |
Output is correct |
13 |
Correct |
4 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 |
7 ms |
604 KB |
Output is correct |
18 |
Correct |
6 ms |
716 KB |
Output is correct |
19 |
Correct |
4 ms |
572 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
1912 KB |
on inputs (80, 199), (81, 199), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |