제출 #825975

#제출 시각아이디문제언어결과실행 시간메모리
825975thimote75Werewolf (IOI18_werewolf)C++14
0 / 100
3976 ms39816 KiB
#include "werewolf.h" #include <bits/stdc++.h> using namespace std; using idata = vector<int>; struct Road { int x, y; Road (int _x, int _y) { x = min(_x, _y); y = max(_x, _y); } }; using t_Roads = vector<Road>; using t_Graph = vector<t_Roads>; t_Graph roads; idata visited; int stage = 0; bool dfs (int source, int target, int left, int right) { if (source == target) return true; if (visited[source] == stage) return false; visited[source] = stage; for (Road &road : roads[source]) { int next = road.x == source ? road.y : road.x; if (road.x < left && right < road.y) continue ; if (next >= left && source < left) continue ; if (dfs(next, target, left, right)) return true; } return false; } idata check_validity(int N, idata X, idata Y, idata S, idata E, idata L, idata R) { int M = X.size(); int Q = S.size(); roads.resize(N); for (int i = 0; i < M; i ++) { Road road (X[i], Y[i]); roads[road.x].push_back(road); roads[road.y].push_back(road); } idata A(Q); visited.resize(N); for (int i = 0; i < Q; i ++) { stage ++; A[i] = dfs(S[i], E[i], L[i], R[i]); } return 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...