#include "werewolf.h"
#include <bits/stdc++.h>
#define pb push_back
#define sz(x) (int)x.size()
using namespace std;
using VI = vector <int>;
const int N = 3e3+1;
int n, m, q;
vector <int> paths[N];
int ans[N];
struct Query {
int st, ed, l, r, id;
// l means I can use city x in human form (l <= x < n)
// r means I can use city x in wolf form (0 <= x <= r)
};
int solve(int st, int ed, int l, int r) {
// cout << st << ' ' << ed << ' ' << l << ' ' << r << '\n';
bool vis[n], vis1[n];
memset(vis, 0, sizeof(vis));
memset(vis1, 0, sizeof(vis1));
vis[st] = 1;
queue <int> bfs; bfs.push(st);
queue <int> bfs1;
while(!bfs.empty()) {
int x = bfs.front(); bfs.pop(); bfs1.push(x);
for (auto el : paths[x]) {
if (vis[el] || el < l) continue;
vis[el] = 1;
bfs.push(l);
}
}
while(!bfs1.empty()) {
int x = bfs1.front(); bfs1.pop();
for (auto el : paths[x]) {
if (vis1[el] || el > r) continue;
vis1[el] = 1;
bfs1.push(l);
}
}
return vis[ed];
}
VI check_validity(int _N, VI X, VI Y, VI ST, VI ED, VI L, VI R) {
n = _N;
m = sz(X);
q = sz(ST);
for (int i = 0; i < m; i++) {
paths[X[i]].pb(Y[i]);
paths[Y[i]].pb(X[i]);
}
vector <Query> queries;
for (int i = 0; i < q; i++)
queries.pb({ST[i], ED[i], L[i], R[i], i});
VI res(q);
for (int i = 0; i < q; i++) {
// res[i] = ans[i];
res[i] = solve(queries[i].st, queries[i].ed, queries[i].l, queries[i].r);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
126 ms |
19564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |