제출 #280485

#제출 시각아이디문제언어결과실행 시간메모리
280485cjoaWerewolf (IOI18_werewolf)C++11
0 / 100
628 ms524292 KiB
#include "werewolf.h" #include <queue> #include <iostream> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; VVI G; const int INF = 1000000000; bool found; VVI vis; void dfs(int form, int u, int dst, int left, int right) { if (u == dst && form == 1) { found = true; return; } for (int v : G[u]) { if (form == 0) { // soy humano if (v < left) continue; } else { // soy werewolf if (v > right) continue; } dfs(form, v, dst, left, right); } if (form == 0) { if (left <= u && u <= right) dfs(1, u, dst, left, right); } } bool solve(int N, int src, int dst, int left, int right) { vis = VVI(2, VI(N, 0)); found = false; dfs(0, src, dst, left, right); return found; } std::vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> S, std::vector<int> E, std::vector<int> L, std::vector<int> R) { G = VVI(N); int M = X.size(); for (int j = 0; j < M; ++j) { int u = X[j], v = Y[j]; G[u].push_back(v); G[v].push_back(u); } int Q = S.size(); vector<int> res(Q); for (int i = 0; i < Q; ++i) { int src = S[i], dst = E[i]; int left = L[i], right = R[i]; res[i] = solve(N, src, dst, left, right); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...