#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
void dfs(int l, int r, vector<vector<int>>& adjlist, int i, vector<bool>& visited)
{
visited[i] = true;
for(int j : adjlist[i])
{
if(!visited[j] && l <= j && j <= r)
{
dfs(l, r, adjlist, j, visited);
}
}
}
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)
{
if(N <= 3000 && (int) X.size() <= 6000 && (int) S.size() <= 3000)
{
int n = N;
vector<vector<int>> adjlist(n, vector<int> (0));
for(int i = 0; i < (int) X.size(); i++)
{
int a = X[i];
int b = Y[i];
adjlist[a].push_back(b);
adjlist[b].push_back(a);
}
vector<int> output(S.size());
for(int t = 0; t < (int) S.size(); t++)
{
int l = L[t];
int r = R[t];
int s = S[t];
int e = E[t];
vector<bool> visited(n, false);
dfs(l, numeric_limits<int>::max()/2, adjlist, s, visited);
for(int i = 0; i < n; i++)
{
if(visited[i] && l <= i && i <= r)
{
dfs(0, r, adjlist, i, visited);
}
}
output[t] = visited[e];
}
return output;
}
}
Compilation message
werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
52 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
234 ms |
644 KB |
Output is correct |
11 |
Correct |
146 ms |
600 KB |
Output is correct |
12 |
Correct |
19 ms |
852 KB |
Output is correct |
13 |
Correct |
228 ms |
644 KB |
Output is correct |
14 |
Correct |
178 ms |
596 KB |
Output is correct |
15 |
Correct |
149 ms |
804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4027 ms |
35924 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
234 ms |
644 KB |
Output is correct |
11 |
Correct |
146 ms |
600 KB |
Output is correct |
12 |
Correct |
19 ms |
852 KB |
Output is correct |
13 |
Correct |
228 ms |
644 KB |
Output is correct |
14 |
Correct |
178 ms |
596 KB |
Output is correct |
15 |
Correct |
149 ms |
804 KB |
Output is correct |
16 |
Execution timed out |
4027 ms |
35924 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |