#include "werewolf.h"
#include "bits/stdc++.h"
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
const int INF = 1e9;
vi check_validity(int N, vi X, vi Y, vi S, vi E, vi L, vi R)
{
vvi adj = vvi(N);
vvi highestOnPath = vvi(N, vi(N, INF));
for (int i = 0; i < (int)X.size(); i++)
{
adj[X[i]].push_back(Y[i]);
adj[Y[i]].push_back(X[i]);
}
priority_queue<pii, vector<pii>, greater<pii>> pqueue;
for (int i = 0; i < N; i++)
{
pqueue.push({i, i});
highestOnPath[i][i] = i;
while (!pqueue.empty())
{
pii cur = pqueue.top();
int curNode = cur.second;
int curMax = cur.first;
pqueue.pop();
if (curMax > highestOnPath[i][curNode])
continue;
for (int a : adj[curNode])
if (max(curMax, a) < highestOnPath[i][a])
{
highestOnPath[i][a] = max(curMax, a);
pqueue.push({highestOnPath[i][a], a});
}
}
}
int Q = S.size();
vi ans(Q);
for (int i = 0; i < Q; i++)
{
vector<int> visited(N, false);
queue<int> queue;
queue.push(S[i]);
visited[S[i]] = true;
while (!queue.empty())
{
int cur = queue.front();
queue.pop();
if (cur < L[i])
continue;
if (highestOnPath[cur][E[i]] <= R[i])
ans[i] = 1;
for (int a : adj[cur])
{
if (visited[a])
continue;
queue.push(a);
visited[a] = true;
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1134 ms |
35972 KB |
Output is correct |
11 |
Correct |
961 ms |
35964 KB |
Output is correct |
12 |
Correct |
377 ms |
35928 KB |
Output is correct |
13 |
Correct |
1047 ms |
35976 KB |
Output is correct |
14 |
Correct |
907 ms |
36048 KB |
Output is correct |
15 |
Correct |
1024 ms |
36048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
307 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1134 ms |
35972 KB |
Output is correct |
11 |
Correct |
961 ms |
35964 KB |
Output is correct |
12 |
Correct |
377 ms |
35928 KB |
Output is correct |
13 |
Correct |
1047 ms |
35976 KB |
Output is correct |
14 |
Correct |
907 ms |
36048 KB |
Output is correct |
15 |
Correct |
1024 ms |
36048 KB |
Output is correct |
16 |
Runtime error |
307 ms |
524288 KB |
Execution killed with signal 9 |
17 |
Halted |
0 ms |
0 KB |
- |