Submission #1082274

#TimeUsernameProblemLanguageResultExecution timeMemory
1082274jer033Werewolf (IOI18_werewolf)C++17
15 / 100
4074 ms29260 KiB
#include "werewolf.h" #include <bits/stdc++.h> 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 Q = S.size(); std::vector<int> answers(Q); vector<vector<int>> edges(N); int M = X.size(); for (int i=0; i<M; i++) { int x = X[i]; int y = Y[i]; edges[x].push_back(y); edges[y].push_back(x); } for (int i = 0; i < Q; i++) { int l = L[i]; int r = R[i]; int s = S[i]; int e = E[i]; //avoid cities less than l in human form vector<bool> human(N, 0); queue<int> visitlist; human[s] = 1; visitlist.push(s); while (!visitlist.empty()) { int k = visitlist.front(); visitlist.pop(); for (int x: edges[k]) { if ((human[x]==0) and (x>=l)) { human[x] = 1; visitlist.push(x); } } } //avoid cities greater than r in wolf form vector<bool> wolf(N, 0); //use the same visitlist; wolf[e] = 1; visitlist.push(e); while (!visitlist.empty()) { int k = visitlist.front(); visitlist.pop(); for (int x: edges[k]) { if ((wolf[x]==0) and (x<=r)) { wolf[x] = 1; visitlist.push(x); } } } answers[i] = 0; for (int j = 0; j<N; j++) { if ((human[j]) and (wolf[j])) answers[i] = 1; } } return answers; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...