This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
void Reigai(int H, int W, int K) {
vector<int> vec;
int cnt = H * W;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
for (int k = 0; k < H; k++) {
for (int l = 0; l < W; l++) {
if (abs(i - k) + abs(j - l) != K) continue;
int c1 = i * W + j;
int c2 = k * W + l;
if (c1 > c2) continue;
add_and(vector<int>{c1, c2});
vec.push_back(cnt);
cnt++;
}
}
}
}
add_or(vec);
}
void solve_Subtask7(int H, int W) {
for (int i = 0; i < H - 1; i++) {
int c1 = H * W + i;
int c2 = H * W + (i + 1);
add_and(vector<int>{c1, c2});
}
for (int i = 0; i < W - 1; i++) {
int c1 = H * W + H + i;
int c2 = H * W + H + (i + 1);
add_and(vector<int>{c1, c2});
}
int base = H * W + H + W + (H - 1) + (W - 1);
vector<int> d1; for (int i = 0; i < H; i++) d1.push_back(H * W + i);
vector<int> d2; for (int i = 0; i < W; i++) d2.push_back(H * W + H + i);
vector<int> d3; for (int i = 0; i < H - 1; i++) d3.push_back(H * W + H + W + i);
vector<int> d4; for (int i = 0; i < W - 1; i++) d4.push_back(H * W + H + W + (H - 1) + i);
add_xor(d1);
add_xor(d2);
add_xor(d3);
add_xor(d4);
add_and(vector<int>{base + 0, base + 3});
add_and(vector<int>{base + 1, base + 2});
add_or(vector<int>{base + 4, base + 5});
}
void construct_network(int H, int W, int K) {
if (H == 1 || W == 1) {
Reigai(H, W, K);
return;
}
// Step #1. Yoko
for (int i = 0; i < H; i++) {
vector<int> vec;
for (int j = 0; j < W; j++) vec.push_back(i * W + j);
add_or(vec);
}
// Step #2. Tate
for (int i = 0; i < W; i++) {
vector<int> vec;
for (int j = 0; j < H; j++) vec.push_back(j * W + i);
add_or(vec);
}
solve_Subtask7(H, W);
}
# | 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... |