Submission #434165

#TimeUsernameProblemLanguageResultExecution timeMemory
434165OdaveyGame (IOI14_game)C++14
0 / 100
5 ms9164 KiB
// // ~oisín~ C++ Template // #include <bits/stdc++.h> #define MX_N 5001 #define mp make_pair #define mod7 1000000007 #define modpi 314159 #define PI 3.141592653589793238 #define pb push_back #define FastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define All(a) a.begin(),a.end() #define fi first #define se second #define ll long long int #define ull unsigned long long int int kx[8] = {+2, +2, -2, -2, +1, +1, -1, -1}; int ky[8] = {+1, -1, +1, -1, +2, -2, +2, -2}; int d9x[9] = {+1, +1, +1, +0, +0, +0, -1, -1, -1}; int d9y[9] = {+1, +0, -1, +1, +0, -1, +1, +0, -1}; int dx4[4] = {+0, +0, +1, -1}; int dy4[4] = {+1, -1, +0, +0}; ll gcd(ull a, ull b){ return (a==0)?b:gcd(b%a,a); } ll lcm(ull a, ull b){ return a*(b/gcd(a,b)); } const long long INF = 1e18; using namespace std; int V; int AM[1501][1501]; int p[1501]; set<int> valid_edges[1501]; void initialize(int n){ memset(AM, -1, sizeof(AM)); V = n; for(int u=0;u<V;++u){ for(int v=0;v<V;++v){ if(v != u){ valid_edges[u].insert(v); } } } p[0] = -1; for(int u=1;u<V;++u){ p[u] = 0; valid_edges[u].erase(0); } return; } int hasEdge(int u, int v){ if(AM[u][v] != -1){ return AM[u][v]; } if(p[v] == u){ swap(u, v); } if(p[u] == v){ if(valid_edges[u].size() == 0){ return AM[u][v] = 1; }else{ int w = *(valid_edges[u].begin()); valid_edges[w].erase(u); valid_edges[u].erase(w); p[u] = w; return AM[u][v] = 0; } }else{ valid_edges[u].erase(v); valid_edges[v].erase(u); return AM[u][v] = 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...