Submission #171494

# Submission time Handle Problem Language Result Execution time Memory
171494 2019-12-28T20:16:11 Z nobik Vision Program (IOI19_vision) C++14
0 / 100
18 ms 2552 KB
#include "vision.h"
#include <bits/stdc++.h>

using namespace std;

int AtLeastK(const vector<int>& xors, int k) {
	int aux = add_not(0);
	int zero = add_and({0, aux});
	int n = static_cast<int>(xors.size());
	vector<int> inputs;
	for (int i = 0; i < n - k + 1; ++i) {
		int aux_and = add_and({xors[i], xors[i + k - 1]});
		inputs.push_back(aux_and);
	}

	return inputs.empty() ? zero : add_or(inputs);
}

pair<int, int> GetVars(const vector<int>& xors, int k) {
	int x = AtLeastK(xors, k);
	int y = AtLeastK(xors, k + 1);
	int first = add_not(x);
	int z = add_not(y);
	int second = add_and({x, z});
	return {first, second};
}

void construct_network(int H, int W, int K) {
	map<int, vector<pair<int, int>>> diag[2];

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			diag[0][i + j].emplace_back(i, j);
			diag[1][i - j].emplace_back(i, j);
		}
	}

	vector<int> xors[2];
	for (int d = 0; d < 2; ++d) {
		for (const auto& item: diag[d]) {
			vector<int> inputs;
			if (!xors[d].empty()) inputs.push_back(xors[d].back());
			for (const auto& point: item.second) {
				inputs.push_back(point.first * W + point.second);
			}

			xors[d].push_back(add_xor(inputs));
		}
	}

	auto first = GetVars(xors[0], K);
	auto second = GetVars(xors[1], K);

	int x = add_and({first.first, second.second});
	int y = add_and({second.first, first.second});

	add_or({x, y});
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 2552 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -