#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
/*
0 -> H - 1 : is one in this row
H -> H + W - 1 : is one in this col
H + W -> both in same row
H + W + 1 -> H + 2 * W : in adj columns for I
H * 2 + W + 1 : in adj columns
H * 2 + W + 2 : case 1 ans
H * 2 + W + 3 : both in same col
H * 2 + W + 4 -> H * 2 + W + 4 + H - 1 : in adj rows for I
*/
void construct_network(int H, int W, int K) {
int cnt = 0;
for (int i = 0; i < H; i++) {
vi cur;
for (int j = 0; j < W; j++) cur.push_back(i * W + j);
add_or(cur);
cnt++;
}
for (int i = 0; i < W; i++) {
vi cur;
for (int j = 0; j < H; j++) cur.push_back(j * W + i);
add_or(cur);
cnt++;
}
// both in same row
vi x;
for (int i = 0; i < H; i++) x.push_back(H * W + i);
add_xor(x);
cnt++;
// both in adj col for I
x.clear();
for (int i = 0; i < W - 1; i++) {
add_and({H * W + H + i, H * W + H + i + 1});
cnt++;
}
// both actually in adj col
vi t;
for (int i = H + W + 1; i <= H * 2 + W; i++) t.push_back(H * W + i);
add_xor(t);
cnt++;
// case 1 ans
add_and({H + W, H * 2 + W + 2});
cnt++;
// both in same col
x.clear();
for (int i = 0; i < H; i++) x.push_back(H * W + H + i);
add_xor(x);
cnt++;
// both in adj row for I
x.clear();
for (int i = 0; i < H - 1; i++) {
add_and({H * W + i, H * W + i + 1});
cnt++;
}
// both actually in adj row
t.clear();
for (int i = H * 2 + W + 4; i <= H * 2 + W + 4 + H - 1; i++) t.push_back(i);
add_xor(t);
cnt++;
// case 2 ans
add_and({H * W + H + H, H * W + cnt - 1});
cnt++;
// overall ans
add_and({H * 2 + W + 2, H * W + cnt - 1});
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |