Submission #618809

#TimeUsernameProblemLanguageResultExecution timeMemory
618809joelauVision Program (IOI19_vision)C++14
100 / 100
46 ms4536 KiB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> V,V1,V2,V3,V4;
 
void construct_network(int H, int W, int K) {
	int n = H*W;
	for (int k = -W+1; k < H; ++k) {
		V.clear();
		for (int i = 0; i < H; ++i) {
			int j = i-k;
			if (j >= 0 && j < W) V.push_back(i*W+j);
		}
		add_or(V); n++;
	}
	V.clear();
	for (int i = 0; i < H+W-1; ++i) V.push_back(H*W+i);
	add_xor(V); n++;
	V1.push_back(n-1); V3.push_back(n-1);
	for (int k = 0; k < H+W-1; ++k) {
		V.clear();
		for (int i = 0; i < H; ++i) {
			int j = k-i;
			if (j >= 0 && j < W) V.push_back(i*W+j);
		}
		add_or(V); n++;
	}
	V.clear();
	for (int i = 0; i < H+W-1; ++i) V.push_back(H*W+H+W+i);
	add_xor(V); n++;
	V2.push_back(n-1); V4.push_back(n-1);
	for (int i = 0; i+K < H+W-1; ++i) {
		V.clear();
		for (int j = 0; j <= K; ++j) V.push_back(H*W+i+j);
		add_or(V); add_xor(V); add_not(n+1); add_and({n,n+2}); n += 4;
		V1.push_back(n-1);
	}
	for (int i = 0; i+K < H+W-1; ++i) {
		V.clear();
		for (int j = 0; j <= K; ++j) V.push_back(H*W+H+W+i+j);
		add_or(V); add_xor(V); add_not(n+1); add_and({n,n+2}); n += 4;
		V2.push_back(n-1);
	}
	for (int i = 0; i+K-1 < H+W-1; ++i) {
		V.clear();
		for (int j = 0; j < K; ++j) V.push_back(H*W+i+j);
		add_or(V); add_xor(V); add_not(n+1); add_and({n,n+2}); n += 4;
		V3.push_back(n-1);
	}
	for (int i = 0; i+K-1 < H+W-1; ++i) {
		V.clear();
		for (int j = 0; j < K; ++j) V.push_back(H*W+H+W+i+j);
		add_or(V); add_xor(V); add_not(n+1); add_and({n,n+2}); n += 4;
		V4.push_back(n-1);
	}
	add_or(V1); add_or(V2); add_or(V3); add_or(V4); n += 4;
	add_and({n-4,n-3}); add_and({n-2,n-1}); n += 2;
	add_not(n-1); n++;
	add_and({n-3,n-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...