Submission #1063684

#TimeUsernameProblemLanguageResultExecution timeMemory
1063684pawnedGame (IOI14_game)C++17
0 / 100
10 ms18012 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;

#include "game.h"

const int MAX = 1505;

int N;

vector<vi> adj(MAX, vi(MAX, 0));
// 0 if not done
// 1 if missing
// 2 if filled

void initialize(int n) {
	N = n;
}

int hasEdge(int u, int v) {
/*	cout<<"adj: "<<endl;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cout<<adj[i][j]<<" ";
		}
		cout<<endl;
	}*/
	// check if connecting u to v makes any "bad triangle"
	// bad triangle u, v, w if (u, v) = 2, (u, w) = 2, and (v, w) isn't 1
	// or if (v, w) = 2 and (u, w) isn't 1
	bool can = true;
	for (int i = 0; i < N; i++) {
		if (adj[u][i] == 2 && adj[v][i] != 1)
			can = false;
		if (adj[v][i] == 2 && adj[u][i] != 1)
			can = false;
	}
	if (can) {
		adj[u][v] = 2;
		adj[v][u] = 2;
		return 1;
	}
	else {
		adj[u][v] = 1;
		adj[v][u] = 1;
		return 0;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...