Submission #1195353

#TimeUsernameProblemLanguageResultExecution timeMemory
1195353madamadam3Vision Program (IOI19_vision)C++20
0 / 100
11 ms1860 KiB
#include "vision.h"
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define each(a, x) for (auto &x : a) 
#define srt(x) sort(all(x))
#define sz(x) (int) (x).size()
#define pb push_back
#define trace(x) for (auto &el : x) cout << el << " "

using pi = pair<int, int>;
using vi = vector<int>;
using vpi = vector<pi>;

int H, W, K;

int coord_to_int(int i, int j) {
	return i * W + j;
}

int instruction_to_int(int i) {
	return H * W + i;
}

pi int_to_coord(int inp) {
	return {inp / W, inp % W};
}

int manhattan(int x1, int y1, int x2, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}

void construct_network(int _H, int _W, int _K) {
	H = _H; W = _W; K = _K;

	int cIdx = 0;
	int rIdx = 0;
	int acIdx = 0;
	int arIdx = 0;

	FOR(i, 0, H) {
		vi xors;
		FOR(j, 0, W) {
			xors.pb(coord_to_int(i, j));
		}
		rIdx = add_xor(xors) + 1;
	}

	FOR(j, 0, W) {
		vi xors;
		FOR(i, 0, H) {
			xors.pb(coord_to_int(i, j));
		}
		acIdx = add_xor(xors) + 1;
	}


	FOR(i, 0, H) {
		vi ands;
		FOR(j, 0, W) {
			ands.pb(coord_to_int(i, j));
		}
		arIdx = add_and(ands) + 1;
	}

	FOR(j, 0, W) {
		vi ands;
		FOR(i, 0, H) {
			ands.pb(coord_to_int(i, j));
		}
		add_and(ands);
	}

	// answer = (CUMXOR OF AND OF ALL ROWS)
	vi colxor; FOR(i, 0, W) colxor.pb(arIdx + i);
	int r1 = add_xor(colxor);
	vi rowxor; FOR(i, 0, H) rowxor.pb(acIdx + i);
	int r2 = add_xor(rowxor);
	vi coland; FOR(i, 0, W) coland.pb(rIdx + i);
	int r3 = add_xor(coland);
	vi rowand; FOR(i, 0, H) rowand.pb(cIdx + i);
	int r4 = add_xor(rowand);
	int r5 = add_not(r2);
	int r6 = add_not(r4);

	int r7 = add_and({r1, r5});
	int r8 = add_and({r3, r6});
	int r9 = add_or({r7, r8});

	// if K = 1 and the answer is yes, then they are either in the same column or same row (have to be)


	// vpi a, b;
	// vector<vi> potential(H*W, vi());
	// FOR(i, 0, H*W) {
	// 	pi coords = int_to_coord(i);
	// 	FOR(j, i + 1, H*W) {
	// 		pi coords2 = int_to_coord(j);
	// 		if (manhattan(coords.first, coords.second, coords2.first, coords2.second) != K) continue;
	// 		potential[i].pb(coord_to_int(coords2.first, coords2.second));
	// 	}
	// }

	// int tl_instructions = 0;
	// FOR(i, 0, H*W) {
	// 	if (sz(potential[i]) > 0) {
	// 		add_or(potential[i]);
	// 		add_and({instruction_to_int(2*tl_instructions), i});
	// 		tl_instructions++;
	// 	}
	// }

	// vi ors;
	// FOR(i, 0, tl_instructions) {
	// 	ors.pb(instruction_to_int(2*i+1));
	// }

	// add_or(ors);
}
#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...