# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
276113 |
2020-08-20T10:53:26 Z |
doowey |
Werewolf (IOI18_werewolf) |
C++14 |
|
1142 ms |
116900 KB |
#include <bits/stdc++.h>
#include "werewolf.h"
using namespace std;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
int n;
const int N = (int)2e5 + 10;
vector<int> T[N];
int par[N];
vector<int> T1[N];
vector<int> T2[N];
int fin(int x){
if(par[x]==x)return x;
return par[x]=fin(par[x]);
}
int S[N], E[N], L[N], R[N];
int t1[N], t2[N];
vector<int> sol;
vector<int> i1[N];
vector<int> i2[N];
int tin[N], tout[N];
int ti;
void dfs1(int u){
tin[u] = ++ti;
for(auto x : T2[u]){
dfs1(x);
}
tout[u] = ti;
}
vector<int> tq[N];
set<int> un[N];
void dfs2(int u){
un[u].insert(tin[u]);
for(auto x : T1[u]){
dfs2(x);
if(un[x].size() > un[u].size())
swap(un[x], un[u]);
for(auto x : un[x]){
un[u].insert(x);
}
un[x].clear();
}
for(auto p : tq[u]){
auto it = un[u].lower_bound(tin[t2[p]]);
if(it == un[u].end() || (*it) > tout[t2[p]])
sol[p]=0;
else
sol[p]=1;
}
}
vector<int> check_validity(int _n,vector<int> X,vector<int> Y,vector<int> _S, vector<int> _E,vector<int> _L, vector<int> _R) {
n = _n;
for(int i = 0 ; i < n; i ++ )
par[i] = i;
int m = X.size();
int us, vs;
int qq = _S.size();
sol.resize(qq);
for(int i = 0 ; i < qq; i ++ ){
S[i] = _S[i];
E[i] = _E[i];
L[i] = _L[i];
R[i] = _R[i];
}
for(int i = 0 ; i < qq; i ++ ){
i1[L[i]].push_back(i);
i2[R[i]].push_back(i);
}
for(int i = 0 ; i < m ; i ++ ){
us = X[i];
vs = Y[i];
if(us > vs)
swap(us, vs);
T[us].push_back(vs);
}
for(int i = n - 1; i >= 0 ; i -- ){
for(auto &x : T[i]){
x=fin(x);
if(x != i){
T1[i].push_back(x);
par[x] = i;
}
}
for(auto x : i1[i]){
t1[x]=fin(S[x]);
}
}
for(int i = 0 ; i < n; i ++ ){
T[i].clear();
par[i] = i;
}
for(int i = 0 ; i < m; i ++ ){
us = X[i];
vs = Y[i];
if(us < vs) swap(us, vs);
T[us].push_back(vs);
}
for(int i = 0 ; i < n; i ++ ){
for(auto &x : T[i]){
x = fin(x);
if(x != i){
T2[i].push_back(x);
par[x] = i;
}
}
for(auto x : i2[i]){
t2[x]=fin(E[x]);
}
}
dfs1(n-1);
for(int i = 0 ; i < qq ; i ++ ){
tq[t1[i]].push_back(i);
}
dfs2(0);
return sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
38016 KB |
Output is correct |
2 |
Correct |
27 ms |
38016 KB |
Output is correct |
3 |
Correct |
36 ms |
38016 KB |
Output is correct |
4 |
Correct |
31 ms |
37896 KB |
Output is correct |
5 |
Correct |
31 ms |
38016 KB |
Output is correct |
6 |
Correct |
30 ms |
38008 KB |
Output is correct |
7 |
Correct |
29 ms |
38008 KB |
Output is correct |
8 |
Correct |
28 ms |
38008 KB |
Output is correct |
9 |
Correct |
29 ms |
38008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
38016 KB |
Output is correct |
2 |
Correct |
27 ms |
38016 KB |
Output is correct |
3 |
Correct |
36 ms |
38016 KB |
Output is correct |
4 |
Correct |
31 ms |
37896 KB |
Output is correct |
5 |
Correct |
31 ms |
38016 KB |
Output is correct |
6 |
Correct |
30 ms |
38008 KB |
Output is correct |
7 |
Correct |
29 ms |
38008 KB |
Output is correct |
8 |
Correct |
28 ms |
38008 KB |
Output is correct |
9 |
Correct |
29 ms |
38008 KB |
Output is correct |
10 |
Correct |
37 ms |
38904 KB |
Output is correct |
11 |
Correct |
34 ms |
38912 KB |
Output is correct |
12 |
Correct |
34 ms |
38904 KB |
Output is correct |
13 |
Correct |
40 ms |
38928 KB |
Output is correct |
14 |
Correct |
35 ms |
38912 KB |
Output is correct |
15 |
Correct |
35 ms |
39016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1142 ms |
99732 KB |
Output is correct |
2 |
Correct |
834 ms |
98352 KB |
Output is correct |
3 |
Correct |
889 ms |
96636 KB |
Output is correct |
4 |
Correct |
870 ms |
96632 KB |
Output is correct |
5 |
Correct |
1029 ms |
97064 KB |
Output is correct |
6 |
Correct |
929 ms |
98680 KB |
Output is correct |
7 |
Correct |
913 ms |
97016 KB |
Output is correct |
8 |
Correct |
866 ms |
98396 KB |
Output is correct |
9 |
Correct |
739 ms |
95268 KB |
Output is correct |
10 |
Correct |
796 ms |
94712 KB |
Output is correct |
11 |
Correct |
756 ms |
94892 KB |
Output is correct |
12 |
Correct |
844 ms |
96808 KB |
Output is correct |
13 |
Correct |
853 ms |
116640 KB |
Output is correct |
14 |
Correct |
764 ms |
116600 KB |
Output is correct |
15 |
Correct |
742 ms |
116520 KB |
Output is correct |
16 |
Correct |
904 ms |
116648 KB |
Output is correct |
17 |
Correct |
867 ms |
97052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
38016 KB |
Output is correct |
2 |
Correct |
27 ms |
38016 KB |
Output is correct |
3 |
Correct |
36 ms |
38016 KB |
Output is correct |
4 |
Correct |
31 ms |
37896 KB |
Output is correct |
5 |
Correct |
31 ms |
38016 KB |
Output is correct |
6 |
Correct |
30 ms |
38008 KB |
Output is correct |
7 |
Correct |
29 ms |
38008 KB |
Output is correct |
8 |
Correct |
28 ms |
38008 KB |
Output is correct |
9 |
Correct |
29 ms |
38008 KB |
Output is correct |
10 |
Correct |
37 ms |
38904 KB |
Output is correct |
11 |
Correct |
34 ms |
38912 KB |
Output is correct |
12 |
Correct |
34 ms |
38904 KB |
Output is correct |
13 |
Correct |
40 ms |
38928 KB |
Output is correct |
14 |
Correct |
35 ms |
38912 KB |
Output is correct |
15 |
Correct |
35 ms |
39016 KB |
Output is correct |
16 |
Correct |
1142 ms |
99732 KB |
Output is correct |
17 |
Correct |
834 ms |
98352 KB |
Output is correct |
18 |
Correct |
889 ms |
96636 KB |
Output is correct |
19 |
Correct |
870 ms |
96632 KB |
Output is correct |
20 |
Correct |
1029 ms |
97064 KB |
Output is correct |
21 |
Correct |
929 ms |
98680 KB |
Output is correct |
22 |
Correct |
913 ms |
97016 KB |
Output is correct |
23 |
Correct |
866 ms |
98396 KB |
Output is correct |
24 |
Correct |
739 ms |
95268 KB |
Output is correct |
25 |
Correct |
796 ms |
94712 KB |
Output is correct |
26 |
Correct |
756 ms |
94892 KB |
Output is correct |
27 |
Correct |
844 ms |
96808 KB |
Output is correct |
28 |
Correct |
853 ms |
116640 KB |
Output is correct |
29 |
Correct |
764 ms |
116600 KB |
Output is correct |
30 |
Correct |
742 ms |
116520 KB |
Output is correct |
31 |
Correct |
904 ms |
116648 KB |
Output is correct |
32 |
Correct |
867 ms |
97052 KB |
Output is correct |
33 |
Correct |
954 ms |
98936 KB |
Output is correct |
34 |
Correct |
413 ms |
75384 KB |
Output is correct |
35 |
Correct |
977 ms |
104424 KB |
Output is correct |
36 |
Correct |
1040 ms |
98980 KB |
Output is correct |
37 |
Correct |
958 ms |
102920 KB |
Output is correct |
38 |
Correct |
1045 ms |
100124 KB |
Output is correct |
39 |
Correct |
1022 ms |
105360 KB |
Output is correct |
40 |
Correct |
1099 ms |
109940 KB |
Output is correct |
41 |
Correct |
1142 ms |
100600 KB |
Output is correct |
42 |
Correct |
817 ms |
95864 KB |
Output is correct |
43 |
Correct |
1042 ms |
111040 KB |
Output is correct |
44 |
Correct |
829 ms |
101880 KB |
Output is correct |
45 |
Correct |
830 ms |
102524 KB |
Output is correct |
46 |
Correct |
1075 ms |
102436 KB |
Output is correct |
47 |
Correct |
798 ms |
116900 KB |
Output is correct |
48 |
Correct |
791 ms |
116728 KB |
Output is correct |
49 |
Correct |
758 ms |
116812 KB |
Output is correct |
50 |
Correct |
785 ms |
116728 KB |
Output is correct |
51 |
Correct |
1012 ms |
108256 KB |
Output is correct |
52 |
Correct |
862 ms |
108224 KB |
Output is correct |