제출 #763010

#제출 시각아이디문제언어결과실행 시간메모리
763010SanguineChameleon게임 (IOI14_game)C++17
42 / 100
1078 ms3208 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1.5e3 + 20; vector<int> adj[maxn]; int q1[maxn]; int flag1[maxn]; int q2[maxn]; int flag2[maxn]; int t; void initialize(int n) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (j != i) { adj[i].push_back(j); } } } } int hasEdge(int u, int v) { t++; adj[u].erase(find(adj[u].begin(), adj[u].end(), v)); adj[v].erase(find(adj[v].begin(), adj[v].end(), u)); int pt1 = 0; int sz1 = 1; int pt2 = 0; int sz2 = 1; q1[pt1] = u; flag1[u] = t; q2[pt2] = v; flag2[v] = t; while (pt1 < sz1 && pt2 < sz2) { int x = q1[pt1++]; for (auto y: adj[x]) { if (y == v) { return 0; } if (flag1[y] != t) { flag1[y] = t; q1[sz1++] = y; } } x = q2[pt2++]; for (auto y: adj[x]) { if (y == u) { return 0; } if (flag2[y] != t) { flag2[y] = t; q2[sz2++] = y; } } } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...