#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pair<int, int> pii
const int MAX = 3003;
int n, m, q;
vector<int> g[MAX];
bitset<MAX> vis1, vis2;
void dfs1(int node, int p, int l){
vis1[node] = 1;
for(int to : g[node]){
if(vis1[to] || to < l) continue;
dfs1(to, node, l);
}
}
void dfs2(int node, int p, int r){
vis2[node] = 1;
for(int to : g[node]){
if(vis2[to] || to > r) continue;
dfs2(to, node, r);
}
}
vector<int> check_validity(int N, vector<int> X, vector<int> Y,
vector<int> S, vector<int> E,
vector<int> L, vector<int> R){
q = S.size();
n = N;
m = X.size();
for(int i = 0; i < m; i++){
g[X[i]].push_back(Y[i]);
g[Y[i]].push_back(X[i]);
}
vector<int> ans;
for(int i = 0; i < q; i++){
vis1.reset();
vis2.reset();
dfs1(S[i], S[i], L[i]);
dfs2(E[i], E[i], R[i]);
if((vis1 & vis2).count()){
ans.push_back(1);
}
else{
ans.push_back(0);
}
}
return ans;
}
Compilation message
werewolf.cpp:7:9: warning: ISO C++11 requires whitespace after the macro name
7 | #define pair<int, int> pii
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
1108 KB |
Output is correct |
11 |
Correct |
103 ms |
676 KB |
Output is correct |
12 |
Correct |
9 ms |
1016 KB |
Output is correct |
13 |
Correct |
216 ms |
860 KB |
Output is correct |
14 |
Correct |
135 ms |
860 KB |
Output is correct |
15 |
Correct |
173 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
98 ms |
28260 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
1108 KB |
Output is correct |
11 |
Correct |
103 ms |
676 KB |
Output is correct |
12 |
Correct |
9 ms |
1016 KB |
Output is correct |
13 |
Correct |
216 ms |
860 KB |
Output is correct |
14 |
Correct |
135 ms |
860 KB |
Output is correct |
15 |
Correct |
173 ms |
860 KB |
Output is correct |
16 |
Runtime error |
98 ms |
28260 KB |
Execution killed with signal 11 |
17 |
Halted |
0 ms |
0 KB |
- |