#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
432 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
432 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
186 ms |
856 KB |
Output is correct |
11 |
Correct |
108 ms |
848 KB |
Output is correct |
12 |
Correct |
14 ms |
856 KB |
Output is correct |
13 |
Correct |
209 ms |
864 KB |
Output is correct |
14 |
Correct |
113 ms |
852 KB |
Output is correct |
15 |
Correct |
172 ms |
1108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4074 ms |
29260 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
432 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
186 ms |
856 KB |
Output is correct |
11 |
Correct |
108 ms |
848 KB |
Output is correct |
12 |
Correct |
14 ms |
856 KB |
Output is correct |
13 |
Correct |
209 ms |
864 KB |
Output is correct |
14 |
Correct |
113 ms |
852 KB |
Output is correct |
15 |
Correct |
172 ms |
1108 KB |
Output is correct |
16 |
Execution timed out |
4074 ms |
29260 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |