#include "vision.h"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using i64 = long long;
using d64 = long double;
using pi = pair<int, int>;
using pli = pair<i64, i64>;
using ti = tuple<int, int, int>;
using tli = tuple<i64, i64, i64>;
#define iterall(cont) cont.begin(), cont.end()
#define prec(n) setprecision(n) << fixed
void construct_network(int H, int W, int K) {
auto valid = [H, W](int x, int y) {
return 0 <= x && x < H && 0 <= y && y < W;
};
auto getNum = [W](int x, int y) { return x * W + y; };
int c = H * W;
vector<int> idx1;
for (int s = 0; s < H + W - 1; s++) {
vector<int> tmp;
for (int x = 0; x < H; x++) {
int y = s - x;
if (valid(x, y)) tmp.emplace_back(getNum(x, y));
}
add_or(tmp);
idx1.emplace_back(c++);
}
vector<int> idx2;
for (int s = W - 1; s >= -(H - 1); --s) {
vector<int> tmp;
for (int x = 0; x < H; x++) {
int y = x + s;
if (valid(x, y)) tmp.emplace_back(getNum(x, y));
}
add_or(tmp);
idx2.emplace_back(c++);
}
// K - 1 연속 (False여야 함)
vector<int> idx3_1;
for (int i = 0; i <= idx1.size() - K + 1; i++) {
vector<int> tmp;
copy(idx1.begin() + i, idx1.begin() + i + K - 1, back_inserter(tmp));
add_or(tmp);
add_xor(tmp);
add_xor({c, c + 1});
idx3_1.emplace_back(c + 2);
c += 3;
}
vector<int> idx3_2;
for (int i = 0; i <= idx2.size() - K + 1; i++) {
vector<int> tmp;
copy(idx2.begin() + i, idx2.begin() + i + K - 1, back_inserter(tmp));
add_or(tmp);
add_xor(tmp);
add_xor({c, c + 1});
idx3_2.emplace_back(c + 2);
c += 3;
}
// K 연속 (True여야 함)
vector<int> idx4;
for (int i = 0; i < idx1.size() - K; i++) {
add_and({idx1[i], idx1[i] + K});
idx4.emplace_back(c++);
}
vector<int> idx5;
for (int i = 0; i < idx2.size() - K; i++) {
add_and({idx2[i], idx2[i] + K});
idx5.emplace_back(c++);
}
add_or(idx3_1); // c
add_or(idx3_2); // c+1
add_or(idx4); // c+2
add_or(idx5); // c+3
add_and({c, c + 3}); // c+4
add_and({c + 1, c + 2}); // c+5
add_and({c + 2, c + 3}); // c+6
add_or({c + 4, c + 5, c + 6});
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for (int i = 0; i <= idx1.size() - K + 1; i++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~
vision.cpp:64:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for (int i = 0; i <= idx2.size() - K + 1; i++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~
vision.cpp:76:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
76 | for (int i = 0; i < idx1.size() - K; i++) {
| ~~^~~~~~~~~~~~~~~~~
vision.cpp:81:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
81 | for (int i = 0; i < idx2.size() - K; i++) {
| ~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
640 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |