Submission #520099

#TimeUsernameProblemLanguageResultExecution timeMemory
520099tjd229Game (IOI14_game)C++14
42 / 100
1062 ms2388 KiB
#include "game.h" #include <vector> #include <algorithm> using namespace std; int n; vector<int> edge[1500]; int num[1500], low[1500]; int vis[1500]; int stamp,k; void initialize(int n) { ::n = n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if(i!=j) edge[i].push_back(j); } } } void dfs(int x,int from,int stamp) { num[x] =low[x]= k++; vis[x] = stamp; for (auto nxt : edge[x]) { if (nxt == from) continue; if (vis[nxt] != stamp) { dfs(nxt, x, stamp); low[x] = min(low[x], low[nxt]); } else { low[x] = min(low[x], num[nxt]); } } } void rm(vector<int> &v, int x) { for (auto &y : v) { if (y == x) { y = v.back(); v.pop_back(); return; } } } int hasEdge(int u, int v) { k = 0; dfs(1, -1, ++stamp); if (num[u] > num[v]) u ^= v ^= u ^= v; if (low[v] > num[u]) return 1; rm(edge[u], v); rm(edge[v], u); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...