Submission #738961

#TimeUsernameProblemLanguageResultExecution timeMemory
7389611neGame (IOI14_game)C++14
0 / 100
1 ms256 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<set<int>>pos;
void initialize(int n) {
	pos.resize(n);
	for (int i = 0;i<n;++i){
		for (int j = 0;j<n;++j){
			if (i != j){
				pos[i].insert(j);
			}
		}
	}	
}
int hasEdge(int u, int v) {
	 auto join = [&](int a,int b){
	 	vector<int>temp;
	 	for (auto x:pos[a]){
			if (pos[b].find(x) != pos[b].end()){
				temp.push_back(x);
			}
		}
		for (auto x:pos[b]){
			if (pos[a].find(x) != pos[a].end()){
				temp.push_back(x);
			}
		}
		for (auto x:temp){
			if (pos[a].find(x)!=pos[a].end()){
				pos[a].erase(x);
			}
			if (pos[b].find(x)!=pos[b].end()){
				pos[b].erase(x);
			}
		}
	 };
	 if (pos[u].size() == 1 || pos[v].size() == 1){
	 	join(u,v);
	 	return 1;
	 }
    if (pos[u].find(v)!=pos[u].end()){
    	pos[u].erase(v);
    }
    if (pos[v].find(u)!=pos[v].end()){
    	pos[v].erase(u);
    }
	 return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...