제출 #231910

#제출 시각아이디문제언어결과실행 시간메모리
231910triple_fault게임 (IOI14_game)C++14
42 / 100
1092 ms8676 KiB
#include "game.h" #include <vector> #include <set> #include <queue> #include <cstring> using namespace std; #define MAX 1500 vector<vector<int>> adj_list; set<pair<int, int>> st; int N; void initialize(int n) { for (int i = 0; i < n; ++i) adj_list.push_back(vector<int>{}); N = n; for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) st.insert({i, j}); } int hasEdge(int u, int v) { int n = N; vector<vector<int>> adj2(adj_list); if (u > v) swap(u, v); st.erase({u, v}); for (auto &each: st) { int x = each.first, y = each.second; adj2[x].push_back(y); adj2[y].push_back(x); } queue<int> q; int vis2[n]; memset(vis2, 0, sizeof vis2); q.push(u); vis2[u] = 1; while (!q.empty()) { int num = q.front(); q.pop(); for (auto &each: adj2[num]) { if (vis2[each]) continue; vis2[each] = 1; q.push(each); } } bool pos2 = true; for (int i = 0; i < n; ++i) { if (vis2[i] == 0) pos2 = false; } if (pos2) return 0; adj_list[u].push_back(v); adj_list[v].push_back(u); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...