# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1044043 | yanb | Sky Walking (IOI19_walk) | C++14 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
#include "vision.h"
using namespace std;
void def(int Y, int X, int K) {
vector<int> ox(X);
for (int i = 0; i < X; i++) {
vector<int> Ns(Y);
for (int j = 0; j < Y; j++) {
Ns[j] = j * X + i;
}
ox[i] = add_or(Ns);
}
vector<int> oy(Y);
for (int i = 0; i < Y; i++) {
vector<int> Ns(X);
for (int j = 0; j < X; j++) {
Ns[j] = j + i * X;
}
oy[i] = add_or(Ns);
}
vector<int> dx(X);
vector<int> Ns;
for (int i = 0; i < X; i++) Ns.push_back(ox[i]);
dx[0] = add_xor(Ns);
for (int d = 1; d < X; d++) {
vector<int> Ns;
for (int i = 0; i + d < X; i++) {
Ns.push_back(add_and({ox[i], ox[i + d]}));
}
dx[d] = add_or(Ns);
}
vector<int> dy(Y);
Ns.clear();
for (int i = 0; i < Y; i++) Ns.push_back(oy[i]);
dy[0] = add_xor(Ns);
for (int d = 1; d < Y; d++) {
vector<int> Ns;
for (int i = 0; i + d < Y; i++) {
Ns.push_back(add_and({oy[i], oy[i + d]}));
}
dy[d] = add_or(Ns);
}
Ns.clear();
for (int x = 0; x < X; x++) {
for (int y = 0; y < Y; y++) {
if (x + y == K) {
Ns.push_back(add_and({dx[x], dy[y]}));
}
}
}
add_or(Ns);
}
void hw1(int Y, int X, int K) {
vector<int> Ns;
for (int i = 0; i + K < X * Y; i++) {
Ns.push_back(add_and({i, i + K}));
}
add_or(Ns);
}
void k1(int Y, int X, int K) {
vector<int> ox(X);
for (int i = 0; i < X; i++) {
vector<int> Ns(Y);
for (int j = 0; j < Y; j++) {
Ns[j] = j * X + i;
}
ox[i] = add_or(Ns);
}
vector<int> oy(Y);
for (int i = 0; i < Y; i++) {
vector<int> Ns(X);
for (int j = 0; j < X; j++) {
Ns[j] = j + i * X;
}
oy[i] = add_or(Ns);
}
vector<int> dx(X);
vector<int> Ns;
for (int i = 0; i < X; i++) Ns.push_back(ox[i]);
dx[0] = add_xor(Ns);
for (int d = 1; d < 2 && d < X; d++) {
vector<int> Ns;
for (int i = 0; i + d < X; i++) {
Ns.push_back(add_and({ox[i], ox[i + d]}));
}
dx[d] = add_or(Ns);
}
vector<int> dy(Y);
Ns.clear();
for (int i = 0; i < Y; i++) Ns.push_back(oy[i]);
dy[0] = add_xor(Ns);
for (int d = 1; d < 2 && d < Y; d++) {
vector<int> Ns;
for (int i = 0; i + d < Y; i++) {
Ns.push_back(add_and({oy[i], oy[i + d]}));
}
dy[d] = add_or(Ns);
}
Ns.clear();
for (int x = 0; x < X; x++) {
for (int y = 0; y < Y; y++) {
if (x + y == K) {
Ns.push_back(add_and({dx[x], dy[y]}));
}
}
}
add_or(Ns);
}
void construct_network(int Y, int X, int K) {
if (K == 1) k1(Y, X, K);
else if (Y == 1 || X == 1) hw1(Y, X, K);
else def(Y, X, K);
}