#include <bits/stdc++.h>
// #include "werewolf.h"
using namespace std;
typedef int ll;
// 0 - Wolf
// 1 - Human
vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int>
L, vector<int> R){
vector<vector<ll>> adj(N+1);
ll M = X.size();
for(ll i=0;i<M;i++){
adj[X[i]].push_back(Y[i]);
adj[Y[i]].push_back(X[i]);
}
ll Q = S.size();
vector<int> ans(Q);
for(ll i=0;i<Q;i++){
vector<int> vis(N+1),vis1(N+1),arr(N+1);
queue<ll> q,q1;
q.push(S[i]);
while(!q.empty()){
ll node = q.front();
q.pop();
if(vis[node]==1) continue;
arr[node]=1;
vis[node]=1;
for(auto el:adj[node]){
if(!vis[el]&&el>=L[i]){
q.push(el);
}
}
}
q1.push(E[i]);
while(!q1.empty()){
ll node = q1.front();
q1.pop();
if(vis1[node]==1) continue;
arr[node]+=1;
vis1[node]=1;
for(auto el:adj[node]){
if(!vis1[el]&&el<=R[i]){
q1.push(el);
}
}
}
for(ll j=0;j<N;j++){
if(j>=L[i]&&arr[j]==2&&j<=R[i]){
ans[i]=1;
}
}
// for(ll j=S[i]+1;j<=N;j++){
// // if(arr[j]==2&&j>=L[i]&&j<=R[i]){
// // ans[i]=1;
// // }
// cout<<arr[j]<<endl;
// }
//break;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
436 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
436 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
181 ms |
900 KB |
Output is correct |
11 |
Correct |
95 ms |
888 KB |
Output is correct |
12 |
Correct |
15 ms |
856 KB |
Output is correct |
13 |
Correct |
206 ms |
880 KB |
Output is correct |
14 |
Correct |
106 ms |
868 KB |
Output is correct |
15 |
Correct |
231 ms |
988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4048 ms |
24316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
436 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
181 ms |
900 KB |
Output is correct |
11 |
Correct |
95 ms |
888 KB |
Output is correct |
12 |
Correct |
15 ms |
856 KB |
Output is correct |
13 |
Correct |
206 ms |
880 KB |
Output is correct |
14 |
Correct |
106 ms |
868 KB |
Output is correct |
15 |
Correct |
231 ms |
988 KB |
Output is correct |
16 |
Execution timed out |
4048 ms |
24316 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |