#include <bits/stdc++.h>
#include "werewolf.h"
using namespace std;
using pii = pair<int, int>;
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 = L.size(), m = X.size();
vector<int> ans;
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<vector<int>> dp;
vector<vector<bool>> flag;
function<bool(int, int, int, int, int)> dfs = [&](int nod, bool race, int target, int l, int r)
{
if(flag[nod][race])
return dp[nod][race];
flag[nod][race] = true;
if(!race and l <= nod and nod <= r)
dp[nod][race] = dfs(nod, true, target, l, r);
if(nod == target)
return (dp[nod][race] | race);
for(auto i: g[nod])
{
if(!race and l <= i)
dp[nod][race] |= dfs(i, race, target, l, r);
if(race and i <= r)
dp[nod][race] |= dfs(i, race, target, l, r);
}
return dp[nod][race];
};
for(int i = 0 ; i < Q ; i++)
{
dp = vector<vector<int>> (n, vector<int> (2, 0));
flag = vector<vector<bool>> (n, vector<bool> (2, false));
ans.push_back(dfs(S[i], false, E[i], L[i], R[i]));
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
3 ms |
272 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
3 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
3 ms |
272 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
3 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
1928 ms |
1512 KB |
Output is correct |
11 |
Correct |
1649 ms |
1400 KB |
Output is correct |
12 |
Correct |
1073 ms |
1832 KB |
Output is correct |
13 |
Correct |
1839 ms |
1492 KB |
Output is correct |
14 |
Correct |
1542 ms |
1380 KB |
Output is correct |
15 |
Correct |
1904 ms |
1820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4043 ms |
70408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
3 ms |
272 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
3 ms |
332 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
1928 ms |
1512 KB |
Output is correct |
11 |
Correct |
1649 ms |
1400 KB |
Output is correct |
12 |
Correct |
1073 ms |
1832 KB |
Output is correct |
13 |
Correct |
1839 ms |
1492 KB |
Output is correct |
14 |
Correct |
1542 ms |
1380 KB |
Output is correct |
15 |
Correct |
1904 ms |
1820 KB |
Output is correct |
16 |
Execution timed out |
4043 ms |
70408 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |