#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 100;
int n;
int pref[maxn][maxn];
int suf[maxn][maxn];
vector<int> g[maxn];
int get(int v, int p[]){
if(p[v] == v) return v;
return p[v] = get(p[v], p);
}
void join(int a, int b, int p[]){
p[get(a, p)] = get(b, p);
}
void add(vector<int> &v){
for(int &x: v) x++;
}
vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y,
std::vector<int> S, std::vector<int> E,
std::vector<int> L, std::vector<int> R){
add(X); add(Y); add(S); add(E); add(L); add(R);
for(int i = 0; i < X.size(); i++){
g[X[i]].push_back(Y[i]);
g[Y[i]].push_back(X[i]);
}
n = N;
for(int i = 1; i <= n; i++){
pref[0][i] = suf[n+1][i] = i;
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
pref[i][j] = pref[i-1][j];
}
for(int to: g[i]){
if(to < i) join(to, i, pref[i]);
}
}
for(int i = n; i > 0; i--){
for(int j = 1; j <= n; j++){
suf[i][j] = suf[i+1][j];
}
for(int to: g[i]){
if(to > i) join(to, i, suf[i]);
}
}
vector<int> ans;
for(int i = 0; i < S.size(); i++){
int s = S[i], e = E[i];
int l = L[i], r = R[i];
int res = 0;
for(int k = l; k <= r; k++){
if(get(s, suf[l]) == get(k, suf[l]) && get(k, pref[r]) == get(e, pref[r])){
res = 1;
}
}
ans.push_back(res);
}
return ans;
}
Compilation message
werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i = 0; i < X.size(); i++){
| ~~^~~~~~~~~~
werewolf.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i = 0; i < S.size(); i++){
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2820 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2908 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2820 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2908 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
80 ms |
73680 KB |
Output is correct |
11 |
Correct |
80 ms |
73688 KB |
Output is correct |
12 |
Correct |
60 ms |
73548 KB |
Output is correct |
13 |
Correct |
74 ms |
73564 KB |
Output is correct |
14 |
Correct |
63 ms |
73556 KB |
Output is correct |
15 |
Correct |
69 ms |
73776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
127 ms |
50256 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2820 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2908 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
80 ms |
73680 KB |
Output is correct |
11 |
Correct |
80 ms |
73688 KB |
Output is correct |
12 |
Correct |
60 ms |
73548 KB |
Output is correct |
13 |
Correct |
74 ms |
73564 KB |
Output is correct |
14 |
Correct |
63 ms |
73556 KB |
Output is correct |
15 |
Correct |
69 ms |
73776 KB |
Output is correct |
16 |
Runtime error |
127 ms |
50256 KB |
Execution killed with signal 11 |
17 |
Halted |
0 ms |
0 KB |
- |