제출 #418772

#제출 시각아이디문제언어결과실행 시간메모리
418772peuch늑대인간 (IOI18_werewolf)C++17
0 / 100
4057 ms15176 KiB
#include "werewolf.h" #include<bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; int n; vector<int> rep, tam; vector<int> ans; void uni(int a, int b); int find(int a); vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R){ n = N; int q = L.size(); int m = X.size(); ans = vector<int> (q); for(int i = 0; i < m; i++) if(X[i] > Y[i]) swap(X[i], Y[i]); for(int i = 0; i < q; i++){ rep = vector<int> (2 * n); tam = vector<int> (2 * n, 1); for(int i = 0; i < 2 * n; i++) rep[i] = i; for(int j = 0; j < m; j++){ if(X[j] <= R[i] && Y[j] <= R[i]){ uni(2 * X[j] + 1, 2 * Y[j] + 1); } if(X[j] >= L[i] && Y[j] >= L[i]){ uni(2 * X[j], 2 * Y[j]); } } for(int j = L[i]; j <= R[i]; j++) uni(2 * j, 2 * j + 1); ans[i] = find(2 * S[i]) == find(2 * E[i] + 1); } return ans; } void uni(int a, int b){ a = find(a); b = find(b); if(a == b) return; if(tam[a] < tam[b]) swap(a, b); rep[b] = a; tam[a] += tam[b]; } int find(int a){ if(a == rep[a]) return a; return find(rep[a]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...