IOI 2019 – Vision Program Problem and Solution

IOI 2019 – Vision Program Problem and Solution

The 31st International Olympiad in Informatics was held in Baku, Azerbaijan in 2019. There were two competition days, with 3 tasks given to the competitors on each day. You can see Vision Program Problem and Solution below.

Problem :

ioi2019problem5

Solution :

#include "vision.h"
using namespace std;

int solve(int H, int W, int K){
	vector<int> X[444], Y[444];
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			X[i+j].push_back(i*W+j);
			Y[i+W-1-j].push_back(i*W+j);
		}
	}
	vector<int> XC, YC, XP, YP;
	vector<int> dap;
	for(int i=0; i<=H+W-2; i++){
		XC.push_back(add_or(X[i]));
		YC.push_back(add_or(Y[i]));
		XP.push_back(add_or(XC));
		YP.push_back(add_or(YC));
		if(i >= K){
			dap.push_back(add_and({XC[i], XP[i-K]}));
			dap.push_back(add_and({YC[i], YP[i-K]}));
		}
	}
	return add_or(dap);
}

void construct_network(int H, int W, int K) {
	if(H+W-2 == K) solve(H, W, K);
	else add_xor({solve(H, W, K), solve(H, W, K + 1)});
}

Explanation :

vision

 444 total views,  1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *