| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1366515 | EJIC_B_KEDAX | Vision Program (IOI19_vision) | C++20 | 0 ms | 0 KiB |
#include "vision.h"
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
void construct_network(int h, int w, int k) {
int fre = h * w;
const int K = 10;
int bi = -1, bj = -1;
vector<vector<int>> sq((h + K - 1) / K, vector<int>((w + K - 1) / K));
for (int i = 0; i < sq.size(); i++) {
for (int j = 0; j < sq[i].size(); j++) {
vector<int> in;
for (int x = 0; x < K && i * K + x < h; x++) {
for (int y = 0; y < K && j * K + y < w; y++) {
in.push_back((i * K + x) * w + j * K + y);
}
}
sq[i][j] = fre;
int v = add_or(in);
fre++;
if (v) {
bi = i;
bj = i;
break;
}
}
}
vector<int> sc;
for (int i = bi; i < min(h, bi + K); i++) {
for (int j = bj; j < min(w, bj + K); j++) {
vector<int> in1, in2;
in1.push_back(x * w + y);
for (int d = 0; d < k; d++) {
int x1 = x + d;
int y1 = y + k - d;
if (x1 >= 0 && x1 < h && y1 >= 0 && y1 < w) {
in2.push_back(x1 * w + y1);
}
}
for (int d = 0; d < k; d++) {
int x1 = x + k - d;
int y1 = y - d;
if (x1 >= 0 && x1 < h && y1 >= 0 && y1 < w) {
in2.push_back(x1 * w + y1);
}
}
for (int d = 0; d < k; d++) {
int x1 = x - d;
int y1 = y - (k - d);
if (x1 >= 0 && x1 < h && y1 >= 0 && y1 < w) {
in2.push_back(x1 * w + y1);
}
}
for (int d = 0; d < k; d++) {
int x1 = x - (k - d);
int y1 = y + d;
if (x1 >= 0 && x1 < h && y1 >= 0 && y1 < w) {
in2.push_back(x1 * w + y1);
}
}
if (!in1.empty() && !in2.empty()) {
// add_or(in1);
add_or(in2);
add_and({in1[0], fre});
sc.push_back(fre + 1);
fre += 2;
}
}
}
assert(!sc.empty());
add_or(sc);
}
