#include "werewolf.h"
#include "bits/stdc++.h"
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
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 < N; i++)
{
adj[X[i]].push_back(Y[i]);
adj[Y[i]].push_back(X[i]);
}
priority_queue<int, vi, greater<int>> pqueue;
for (int i = 0; i < N; i++)
{
pqueue.push(i);
highestOnPath[i][i] = i;
while (!pqueue.empty())
{
int cur = pqueue.top();
pqueue.pop();
for (int a : adj[cur])
if (max(highestOnPath[i][cur], a) < highestOnPath[i][a])
{
highestOnPath[i][a] = max(highestOnPath[i][cur], a);
pqueue.push(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 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
313 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |