Submission #650833

#TimeUsernameProblemLanguageResultExecution timeMemory
650833Markomafko972Game (IOI14_game)C++14
0 / 100
1 ms340 KiB
#include "game.h"
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

int br[1502];
int zbr[1502];
int mora[1502][1502];

void dfs(int x) {
	if (br[x] != 1) return;
	
	br[x] = 0;
	int slj = zbr[x];
	zbr[x] = 0;
	
	br[slj]--;
	zbr[slj] -= x;
	mora[min(x, slj)][max(x, slj)] = 1;
	dfs(slj);
}

void initialize(int n) {
	for (int i = 0; i < n; i++) {
		br[i] = n-1;
		zbr[i] = n*(n-1)/2;
	}
}

int hasEdge(int x, int y) {
	if (x > y) swap(x, y);
	
	if (mora[x][y]) return 1;
	
	br[x]--;
	zbr[x] -= y;
	br[y]--;
	zbr[y] -= x;
	
	if (br[x] == 1) dfs(x);
	if (br[y] == 1) dfs(y);
	
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...