Submission #716343

#TimeUsernameProblemLanguageResultExecution timeMemory
716343ovidiush11Game (IOI14_game)C++14
100 / 100
396 ms11932 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; const int N = 1500 + 5; int n,groups; vector<int> a[15]; void initialize(int num) { int p = 2,k = 0,n = num; while(p < n) { int sz = n / (p*2); if(n % (p*2) != 0)sz++; a[k].resize(sz); for(int i = 0;i < sz;i++) { if(n > i * p * 2 + p)a[k][i] = p * min(p,n - i*p*2-p); else a[k][i] = 0; } k++; p *= 2; } groups = k; return ; } int hasEdge(int u, int v) { if(u > v)swap(u,v); if(u/2 == v/2)return 1; int k = 4; for(int i = 0;i < groups;i++) { int x,y; x = u / k;y = v / k; if(x == y) { a[i][x]--; if(a[i][x] == 0)return 1; else return 0; } k *= 2; } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...