제출 #602358

#제출 시각아이디문제언어결과실행 시간메모리
602358jairRS늑대인간 (IOI18_werewolf)C++17
0 / 100
4094 ms28200 KiB
#include "werewolf.h" #include "bits/stdc++.h" using namespace std; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; const int INF = 1e9; vvi adj; void dfsHuman(int src, vector<bool> &reachable, int L) { if (src < L) return; reachable[src] = true; for (int a : adj[src]) { if (reachable[a]) continue; dfsHuman(a, reachable, L); } } void dfsWolf(int src, vector<bool> &reachable, int R) { if (src > R) return; reachable[src] = true; for (int a : adj[src]) { if (reachable[a]) continue; dfsHuman(a, reachable, R); } } vi check_validity(int N, vi X, vi Y, vi S, vi E, vi L, vi R) { adj = vvi(N); for (int i = 0; i < N; i++) { adj[X[i]].push_back(Y[i]); adj[Y[i]].push_back(X[i]); } int Q = S.size(); vi ans(Q, false); for (int i = 0; i < Q; i++) { vector<bool> reachableHuman(N, false); dfsHuman(S[i], reachableHuman, L[i]); vector<bool> reachableWolf(N, false); dfsWolf(E[i], reachableWolf, R[i]); for (int a = L[i]; a <= R[i]; a++) ans[i] |= (reachableHuman[a] && reachableWolf[a]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...