#include "werewolf.h"
#include <cstring>
using namespace std;
using vi = vector<int>;
#define sz(x) (int)x.size()
const int MAXN = 2e5;
vi G[MAXN];
bool vis[MAXN], can;
int s, e, l, r;
void DFS(int u, int t) {
if(u == e) can = true;
vis[u] = true;
for(int v : G[u]) {
if(!vis[v]) {
if(t == 0){
if(v >= l) DFS(v, t);
else if(v <= r && u <= r) DFS(v, 1);
} else {
if(v <= r) DFS(v, t);
}
}
}
}
vi check_validity(int N, vi X, vi Y, vi S, vi E, vi L, vi R) {
for(int i=0; i<sz(X); i++) {
int u = X[i], v = Y[i];
G[u].push_back(v);
G[v].push_back(u);
}
int Q = sz(S);
vi ret(Q);
for(int i=0; i<Q; i++) {
s = S[i]; e = E[i]; l = L[i]; r = R[i];
can = false;
memset(vis, false, sizeof(vis));
DFS(s, 0);
ret[i] = (can)? 1 : 0;
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
5196 KB |
Output is correct |
2 |
Correct |
4 ms |
5068 KB |
Output is correct |
3 |
Correct |
4 ms |
5068 KB |
Output is correct |
4 |
Correct |
5 ms |
5068 KB |
Output is correct |
5 |
Incorrect |
5 ms |
5068 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
5196 KB |
Output is correct |
2 |
Correct |
4 ms |
5068 KB |
Output is correct |
3 |
Correct |
4 ms |
5068 KB |
Output is correct |
4 |
Correct |
5 ms |
5068 KB |
Output is correct |
5 |
Incorrect |
5 ms |
5068 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4073 ms |
38664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
5196 KB |
Output is correct |
2 |
Correct |
4 ms |
5068 KB |
Output is correct |
3 |
Correct |
4 ms |
5068 KB |
Output is correct |
4 |
Correct |
5 ms |
5068 KB |
Output is correct |
5 |
Incorrect |
5 ms |
5068 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |