#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define F first
#define S second
#define sz(x) (ll)x.size()
#define MID ((l+r)/2)
#define pb push_back
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<" "<<#w<<": "<<w<<endl;
#define INF 1e9
typedef vector <ll> vi;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;
void printVct(vi &v, string s =""){
if (sz(s) > 0) cout<<s<<": "<<endl;
for (ll i=0; i<sz(v); i++){
cout<<v[i]<<" ";
}
}
vector <vi> adj;
ll n,m;
void bfs(ll s, ll l, ll r, vi &vis){
queue <ll> q;
vis.assign(n, 0);
ll f;
q.push(s);
while (!q.empty()){
f = q.front();
q.pop();
vis[f] = 1;
for (ll i=0; i<sz(adj[f]); i++){
ll c= adj[f][i];
if (!vis[c] && c >= l && c <= r){
q.push(adj[f][i]);
}
}
}
}
vi check_validity(int N, vi X, vi Y, vi S, vi E, vi L, vi R){
m = sz(X),n = N;
adj.assign(n, vi());
for (ll i=0;i<m; i++){
adj[X[i]].pb(Y[i]);
adj[Y[i]].pb(X[i]);
}
vi ans;
vi vis1, vis2;
ll q = sz(L);
// dbg(q);
for (ll i=0; i<q; i++){
// dbg(i);
bool ok = false;
ll s = S[i], e= E[i], l = L[i], r = R[i];
bfs(s, l, INF, vis1);
bfs(e, -1, r, vis2);
// printVct(vis1, "vis1");
// printVct(vis2, "vis2");
for (ll j= 0; j<n; j++){
if (vis1[j] == 1 && vis2[j] == 1){
ok = true;
break;
}
}
ans.pb(ok);
// dbg(ok);
}
// cout<<"ans:";
// printVct(ans);
// cout<<endl;
return ans;
}
/*
6 6 3
5 1
1 2
1 3
3 4
3 0
5 2
4 2 1 2
4 2 2 2
5 4 3 4
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
346 ms |
756 KB |
Output is correct |
11 |
Correct |
118 ms |
748 KB |
Output is correct |
12 |
Correct |
22 ms |
724 KB |
Output is correct |
13 |
Correct |
372 ms |
876 KB |
Output is correct |
14 |
Correct |
171 ms |
724 KB |
Output is correct |
15 |
Correct |
600 ms |
836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4049 ms |
22644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
346 ms |
756 KB |
Output is correct |
11 |
Correct |
118 ms |
748 KB |
Output is correct |
12 |
Correct |
22 ms |
724 KB |
Output is correct |
13 |
Correct |
372 ms |
876 KB |
Output is correct |
14 |
Correct |
171 ms |
724 KB |
Output is correct |
15 |
Correct |
600 ms |
836 KB |
Output is correct |
16 |
Execution timed out |
4049 ms |
22644 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |