제출 #299561

#제출 시각아이디문제언어결과실행 시간메모리
299561square1001늑대인간 (IOI18_werewolf)C++14
15 / 100
4018 ms30020 KiB
#include "werewolf.h" #include <queue> #include <vector> #include <algorithm> using namespace std; 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) { int M = X.size(), Q = S.size(); vector<vector<int> > G(N); for(int i = 0; i < M; ++i) { G[X[i]].push_back(Y[i]); G[Y[i]].push_back(X[i]); } vector<int> ans(Q); for(int i = 0; i < Q; ++i) { vector<bool> visa(N), visb(N); queue<int> qa, qb; qa.push(S[i]); visa[S[i]] = true; qb.push(E[i]); visb[E[i]] = true; while(!qa.empty()) { int u = qa.front(); qa.pop(); for(int j : G[u]) { if(j >= L[i] && !visa[j]) { visa[j] = true; qa.push(j); } } } while(!qb.empty()) { int u = qb.front(); qb.pop(); for(int j : G[u]) { if(j <= R[i] && !visb[j]) { visb[j] = true; qb.push(j); } } } for(int j = 0; j < N; ++j) { if(visa[j] && visb[j]) { ans[i] = 1; } } } 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...