Submission #292766

#TimeUsernameProblemLanguageResultExecution timeMemory
292766miss_robotVision Program (IOI19_vision)C++14
55 / 100
31 ms2808 KiB
#include <bits/stdc++.h>
#include "vision.h"

#pragma GCC optimize("O3")

using namespace std;

int ab(int a, int b, int W){
	int x = a/W, X = b/W, y = a%W, Y = b%W;
	if(x > X) swap(x, X);
	if(y > Y) swap(y, Y);
	return X-x+Y-y;
}

void st1(int H, int W, int K){
	int c = 0;
	for(int a = 0; a < H*W; a++)
		for(int b = a+1; b < H*W; b++)
			if(ab(a, b, W) == K) add_and({a, b}), c++;
	vector<int> x;
	for(int i = H*W; i < H*W+c; i++) x.push_back(i);
	add_or(x);
}

void st6(int H, int W, int K){
	int c = 0;
	for(int i = 1; i < H*W; i++)
		if(ab(0, i, W) == K) add_and({i}), c++;
	vector<int> x;
	for(int i = H*W; i < H*W+c; i++) x.push_back(i);
	add_or(x);
}

void st7(int H, int W){
	int t1, t2;
	vector<int> f_ask;
	for(int i = 0; i < H-1; i++){
		vector<int> x, y;
		for(int j = 0; j < W; j++)
			x.push_back(i*W+j),
				y.push_back((i+1)*W+j);
		int ind1 = add_or(x), ind2 = add_or(y);
		f_ask.push_back(add_and({ind1, ind2}));
	}
	int tmp1 = add_or(f_ask), tmp2;
	f_ask.clear();
	for(int j = 0; j < W; j++){
		vector<int> x;
		for(int i = 0; i < H; i++) x.push_back(i*W+j);
		f_ask.push_back(add_xor(x));
	}
	tmp2 = add_or(f_ask);
	tmp2 = add_not(tmp2);
	t1 = add_and({tmp1, tmp2});
	f_ask.clear();
	for(int j = 0; j < W-1; j++){
		vector<int> x, y;
		for(int i = 0; i < H; i++)
			x.push_back(i*W+j),
				y.push_back(i*W+j+1);
		int ind1 = add_or(x), ind2 = add_or(y);
		f_ask.push_back(add_and({ind1, ind2}));
	}
	tmp1 = add_or(f_ask);
	f_ask.clear();
	for(int i = 0; i < H; i++){
		vector<int> x;
		for(int j = 0; j < W; j++) x.push_back(i*W+j);
		f_ask.push_back(add_xor(x));
	}
	tmp2 = add_or(f_ask);
	tmp2 = add_not(tmp2);
	t2 = add_and({tmp1, tmp2});
	add_or({t1, t2});
}

void construct_network(int H, int W, int K) {
	if((H <= 10 && W <= 10) || (H == 1 || W == 1)) st1(H, W, K);
	else if(K == 1) st7(H, W);
	else st6(H, W, K);
}
#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...