Submission #317800

#TimeUsernameProblemLanguageResultExecution timeMemory
317800miss_robotGame (IOI14_game)C++14
42 / 100
1069 ms2680 KiB
#include <bits/stdc++.h>
#include "game.h"

#pragma GCC optimize("O3")

using namespace std;

int n;
vector< vector<int> > g;
vector<int> vis;

void initialize(int N){
	n = N;
	g.resize(n);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++) if(i != j)
			g[i].push_back(j);
}

int hasEdge(int u, int v) {
	if(!binary_search(begin(g[u]), end(g[u]), v)) return 0;
	vis.assign(n, 0);
	deque<int> q;
	q.push_back(u);
	vis[u] = 1;
	while(!q.empty()){
		int w = q.front();
		q.pop_front();
		if(v == w){
			g[u].erase(find(begin(g[u]), end(g[u]), v)), g[v].erase(find(begin(g[v]), end(g[v]), u));
			return 0;
		}
		for(int x : g[w]) if(!vis[x] && (u!=w||v!=x)) vis[x] = 1, q.push_back(x);
	}
	return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...