#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
#define vi vector <int>
int vis[3003];
vector <int> g[3003];
void check(int u, int p, bool state, int l, int r, int e){
if(vis[u] && e != u)
return;
if(u == e){
if(state==0 || r >= p){
vis[u] = 1;
}
return;
}
if(state){
if(u < l)
if(p > r)
return;
else
state = 0;
}
else{
if(u > r)
return;
}
vis[u] = 1;
for(auto v : g[u]){
if(v == p)
continue;
// cout << v << " " << u << " " << state << "\n";
check(v, u, state, l, r, e);
}
}
vi check_validity(int n, vi x, vi y, vi s, vi e, vi L, vi R) {
int m = x.size();
for(int i = 0; i < m; i ++){
g[x[i]].push_back(y[i]);
g[y[i]].push_back(x[i]);
}
int q = s.size();
vector <int> ans;
for(int i = 0; i < q; i ++){
memset(vis, 0, sizeof(vis));
// cout << i << "\n";
check(s[i], s[i], 1, L[i], R[i], e[i]);
ans.push_back(e[i] <= R[i] && vis[e[i]] > 0);
}
return ans;
}
Compilation message
werewolf.cpp: In function 'void check(int, int, bool, int, int, int)':
werewolf.cpp:18:11: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
18 | if(u < l)
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
165 ms |
19672 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |