Submission #536001

#TimeUsernameProblemLanguageResultExecution timeMemory
536001KoDVision Program (IOI19_vision)C++17
100 / 100
96 ms7624 KiB
#include <bits/stdc++.h>
#include "vision.h"
using namespace std;

void construct_network(int H, int W, int K) {
	const auto cell = [&](int x, int y) {
		y -= W - 1;
		if ((x - y) % 2 != 0) return -1;
		const int i = (x + y) / 2;
		const int j = (x - y) / 2;
		if (0 <= i and i < H and 0 <= j and j < W) {
			return i * W + j;
		} else {
			return -1;
		}
	};
	const int N = H + W - 1;
	vector<int> row(N), col(N);
	for (int i = 0; i < N; ++i) {
		vector<int> x, y;
		for (int j = 0; j < N; ++j) {
			const int a = cell(i, j);
			const int b = cell(j, i);
			if (a != -1) x.push_back(a);
			if (b != -1) y.push_back(b);
		}
		row[i] = add_or(x);
		col[i] = add_or(y);
	}
	const auto solve = [&](const int thres) {
		vector<int> x, y;
		for (int k = thres; k <= N; ++k) {
			vector<int> a, b;
			for (int i = 0; i < k - thres; ++i) {
				a.push_back(row[i]);
				b.push_back(col[i]);
			}
			for (int i = k; i < N; ++i) {
				a.push_back(row[i]);
				b.push_back(col[i]);
			}
			x.push_back(add_or(a));
			y.push_back(add_or(b));
		}
		return add_not(add_or({add_and(x), add_and(y)}));
	};
	if (K + 1 == N) add_not(solve(K));
	else add_xor({solve(K), solve(K + 1)});
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...