Submission #754544

#TimeUsernameProblemLanguageResultExecution timeMemory
754544KN200711Game (IOI14_game)C++14
15 / 100
2 ms712 KiB
#include "game.h" # include <bits/stdc++.h> using namespace std; int cek[1501][1501], cnt[1501], ls[1501]; void initialize(int n) { for(int i=0;i<n;i++) { for(int k=0;k<n;k++) { cek[i][k] = -1; } cek[i][i] = 0; cnt[i] = n - 1; if(i != n - 1) ls[i] = n - 1; else ls[i] = n - 2; } } void upd(int f) { while(ls[f] >= 0 && cek[f][ls[f]] != -1) ls[f]--; return; } int hasEdge(int u, int v) { if(cek[u][v] != -1) return cek[u][v]; if(cnt[v] == 1) swap(u, v); if(cnt[u] == 1) { cnt[u] = 0; cek[u][v] = cek[v][u] = 1; cnt[v]--; int a = v; while(cnt[a] == 1) { upd(a); cek[a][ls[a]] = cek[ls[a]][a] = 1; cnt[ls[a]]--; a = ls[a]; } } else { cek[u][v] = cek[v][u] = 0; cnt[u]--; cnt[v]--; int a = v; while(cnt[a] == 1) { upd(a); cek[a][ls[a]] = cek[ls[a]][a] = 1; cnt[ls[a]]--; a = ls[a]; } a = u; while(cnt[a] == 1) { upd(a); cek[a][ls[a]] = cek[ls[a]][a] = 1; cnt[ls[a]]--; a = ls[a]; } } return cek[u][v]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...