제출 #577572

#제출 시각아이디문제언어결과실행 시간메모리
577572Mazaalai게임 (IOI14_game)C++17
42 / 100
1078 ms12732 KiB
#include "game.h" #include <bits/stdc++.h> #define lb lower_bound #define LINE "------------\n" using namespace std; using PII = pair <int, int>; const int N = 1500; // bool path[N][N]; set <int> vals[N]; int n; void initialize(int _n) { n = _n; for (int i = 0; i < n; i++) for (int j = i+1; j < n; j++) { vals[i].insert(j); vals[j].insert(i); // path[i][j] = path[j][i] = 1; } } int hasEdge(int u, int v) { // path[u][v] = path[v][u] = 0; vals[u].erase(v); vals[v].erase(u); if (vals[u].size() > vals[v].size()) swap(u, v); bool vis[n]; memset(vis, 0, sizeof(vis)); queue <int> bfs; bfs.push(u); vis[u] = 1; int reach = 0; // cout << LINE; // cout << u << ' ' << v << '\n'; // for (int i = 0; i < n; i++) { // cout << i <<": "; // for (auto el : vals[i]) cout << el << " "; cout << '\n'; // } while(!bfs.empty()) { reach++; int x = bfs.front(); bfs.pop(); // cout << x << " \n"[reach==n]; // for (int i = 0; i < n; i++) { // if (path[x][i] && !vis[i]) { // bfs.push(i); vis[i] = 1; // } // } for (auto el : vals[x]) { if (!vis[el]) { bfs.push(el); vis[el] = 1; } } } // if (reach != n) path[u][v] = path[v][u] = 1; // cout << reach <<"\n"; if (reach != n) vals[u].insert(v), vals[v].insert(u); return reach == n ? 0 : 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...