#ifndef safar
#include<Joi.h>
#endif
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e4 + 10;
const int Log = 60;
static vector<int> G[N], Gd, T[N], O;
static int mk[N], id[N];
static int fn = 0;
void dfs(int u){
if(fn == Log) return ;
id[u] = fn;
fn ++;
mk[u] = 1;
Gd.pb(u);
for(auto adj : G[u]) if(!mk[adj]) dfs(adj);
}
void DFS(int u){
O.pb(u);
mk[u] = 1;
for(auto adj : G[u]){
if(!mk[adj]) DFS(adj);
}
}
void DFS2(int u){
mk[u] = 1;
for(auto adj : G[u]){
if(!mk[adj]){
T[adj].pb(adj);
for(auto x : T[u]) T[adj].pb(x);
id[adj] = id[T[adj].back()];
T[adj].pop_back();
DFS2(adj);
}
}
}
void Joi(int n, int m, int A[], int B[], ll X, int Tc){
for(int i = 0; i < m; i++){
G[A[i]].pb(B[i]);
G[B[i]].pb(A[i]);
}
dfs(1);
for(auto x : Gd){
fill(mk, mk + N, 1);
for(auto x : Gd) mk[x] = 0;
O.clear();
DFS(x);
for(auto y : O) T[x].pb(y);
}
memset(mk, 0, sizeof mk);
for(auto x : Gd) mk[x] = 1;
for(auto x : Gd) DFS2(x);
assert(n >= 60);
assert(-1 <= Tc);
for(int i = 0; i < n; i++) MessageBoard(i, X >> id[i] & 1);
return ;
}
#ifndef safar
#include<Ioi.h>
#endif
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e4 + 10;
const int Log = 60;
static vector<int> G[N], Gd, T[N], O;
static int mk[N], id[N];
static int fn = 0;
void dfs(int u){
if(fn == Log) return ;
id[u] = fn;
fn ++;
mk[u] = 1;
Gd.pb(u);
for(auto adj : G[u]) if(!mk[adj]) dfs(adj);
}
void DFS(int u){
O.pb(u);
mk[u] = 1;
for(auto adj : G[u]){
if(!mk[adj]) DFS(adj);
}
}
void DFS2(int u){
mk[u] = 1;
for(auto adj : G[u]){
if(!mk[adj]){
T[adj].pb(adj);
for(auto x : T[u]) T[adj].pb(x);
id[adj] = id[T[adj].back()];
T[adj].pop_back();
DFS2(adj);
}
}
}
static ll Ans = 0;
void Find(int u){
mk[u] = 1;
for(auto adj : G[u]){
if(mk[adj]) continue;
ll res = Move(adj);
if(res) Ans |= (1ll << id[adj]);
Find(adj);
Move(u);
}
}
ll Ioi(int n, int m, int A[], int B[], int P, int V, int Tc){
for(int i = 0; i < m; i++){
G[A[i]].pb(B[i]);
G[B[i]].pb(A[i]);
}
dfs(1);
for(auto x : Gd){
fill(mk, mk + N, 1);
for(auto x : Gd) mk[x] = 0;
O.clear();
DFS(x);
for(auto y : O) T[x].pb(y);
}
memset(mk, 0, sizeof mk);
for(auto x : Gd) mk[x] = 1;
for(auto x : Gd) DFS2(x);
if(V) Ans |= (1ll << id[P]);
assert(n >= 60);
assert(-1 <= Tc);
fill(mk, mk + N, 1);
for(auto x : T[P]) mk[x] = 0;
Find(P);
return Ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
2008 KB |
Output is correct |
2 |
Correct |
11 ms |
1996 KB |
Output is correct |
3 |
Correct |
12 ms |
2044 KB |
Output is correct |
4 |
Correct |
11 ms |
1780 KB |
Output is correct |
5 |
Correct |
12 ms |
1976 KB |
Output is correct |
6 |
Correct |
10 ms |
1976 KB |
Output is correct |
7 |
Correct |
12 ms |
1924 KB |
Output is correct |
8 |
Correct |
12 ms |
2052 KB |
Output is correct |
9 |
Correct |
13 ms |
1944 KB |
Output is correct |
10 |
Correct |
10 ms |
1908 KB |
Output is correct |
11 |
Correct |
15 ms |
2248 KB |
Output is correct |
12 |
Correct |
11 ms |
2020 KB |
Output is correct |
13 |
Correct |
11 ms |
1936 KB |
Output is correct |
14 |
Correct |
12 ms |
1940 KB |
Output is correct |
15 |
Correct |
12 ms |
2068 KB |
Output is correct |
16 |
Correct |
13 ms |
1928 KB |
Output is correct |
17 |
Correct |
12 ms |
2060 KB |
Output is correct |
18 |
Correct |
12 ms |
2160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
10208 KB |
Output is correct |
2 |
Correct |
56 ms |
10204 KB |
Output is correct |
3 |
Correct |
57 ms |
10228 KB |
Output is correct |
4 |
Correct |
41 ms |
8896 KB |
Output is correct |
5 |
Correct |
44 ms |
9432 KB |
Output is correct |
6 |
Correct |
47 ms |
9068 KB |
Output is correct |
7 |
Correct |
43 ms |
9140 KB |
Output is correct |
8 |
Correct |
43 ms |
9208 KB |
Output is correct |
9 |
Correct |
44 ms |
9148 KB |
Output is correct |
10 |
Correct |
43 ms |
8652 KB |
Output is correct |
11 |
Correct |
43 ms |
8652 KB |
Output is correct |
12 |
Correct |
40 ms |
8072 KB |
Output is correct |
13 |
Correct |
40 ms |
8108 KB |
Output is correct |
14 |
Correct |
41 ms |
8460 KB |
Output is correct |
15 |
Correct |
43 ms |
8680 KB |
Output is correct |
16 |
Correct |
41 ms |
8636 KB |
Output is correct |
17 |
Correct |
44 ms |
8664 KB |
Output is correct |
18 |
Correct |
44 ms |
8680 KB |
Output is correct |
19 |
Correct |
43 ms |
8652 KB |
Output is correct |
20 |
Correct |
40 ms |
9528 KB |
Output is correct |
21 |
Correct |
41 ms |
9148 KB |
Output is correct |
22 |
Correct |
43 ms |
9260 KB |
Output is correct |
23 |
Correct |
43 ms |
9100 KB |
Output is correct |
24 |
Correct |
44 ms |
8904 KB |
Output is correct |
25 |
Correct |
44 ms |
9196 KB |
Output is correct |
26 |
Correct |
43 ms |
9192 KB |
Output is correct |
27 |
Correct |
44 ms |
9104 KB |
Output is correct |
28 |
Correct |
44 ms |
9164 KB |
Output is correct |
29 |
Correct |
40 ms |
8388 KB |
Output is correct |
30 |
Correct |
48 ms |
8944 KB |
Output is correct |
31 |
Correct |
12 ms |
1792 KB |
Output is correct |
32 |
Correct |
11 ms |
1908 KB |
Output is correct |
33 |
Correct |
12 ms |
1916 KB |
Output is correct |
34 |
Correct |
11 ms |
1992 KB |
Output is correct |
35 |
Correct |
10 ms |
1996 KB |
Output is correct |
36 |
Correct |
10 ms |
2004 KB |
Output is correct |
37 |
Correct |
10 ms |
1908 KB |
Output is correct |
38 |
Correct |
11 ms |
2016 KB |
Output is correct |
39 |
Correct |
11 ms |
2004 KB |
Output is correct |
40 |
Correct |
10 ms |
1980 KB |
Output is correct |
41 |
Correct |
10 ms |
1976 KB |
Output is correct |
42 |
Correct |
10 ms |
2016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
2004 KB |
Output is correct |
2 |
Correct |
11 ms |
1984 KB |
Output is correct |
3 |
Correct |
10 ms |
1992 KB |
Output is correct |
4 |
Correct |
17 ms |
3100 KB |
Output is correct |
5 |
Correct |
15 ms |
3056 KB |
Output is correct |
6 |
Correct |
15 ms |
3332 KB |
Output is correct |
7 |
Correct |
15 ms |
3220 KB |
Output is correct |
8 |
Correct |
15 ms |
3220 KB |
Output is correct |
9 |
Correct |
39 ms |
9912 KB |
Output is correct |
10 |
Correct |
40 ms |
10152 KB |
Output is correct |
11 |
Correct |
38 ms |
9900 KB |
Output is correct |
12 |
Correct |
10 ms |
2016 KB |
Output is correct |
13 |
Correct |
11 ms |
2004 KB |
Output is correct |
14 |
Correct |
10 ms |
2016 KB |
Output is correct |
15 |
Correct |
10 ms |
2016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
10076 KB |
Output is correct |
2 |
Correct |
56 ms |
10644 KB |
Output is correct |
3 |
Correct |
62 ms |
10620 KB |
Output is correct |
4 |
Correct |
43 ms |
8924 KB |
Output is correct |
5 |
Correct |
45 ms |
9712 KB |
Output is correct |
6 |
Correct |
46 ms |
9380 KB |
Output is correct |
7 |
Correct |
45 ms |
9336 KB |
Output is correct |
8 |
Correct |
43 ms |
9388 KB |
Output is correct |
9 |
Correct |
44 ms |
9468 KB |
Output is correct |
10 |
Correct |
43 ms |
8904 KB |
Output is correct |
11 |
Correct |
45 ms |
8904 KB |
Output is correct |
12 |
Correct |
40 ms |
8332 KB |
Output is correct |
13 |
Correct |
40 ms |
8456 KB |
Output is correct |
14 |
Correct |
45 ms |
8704 KB |
Output is correct |
15 |
Correct |
46 ms |
8944 KB |
Output is correct |
16 |
Correct |
44 ms |
8796 KB |
Output is correct |
17 |
Correct |
43 ms |
8932 KB |
Output is correct |
18 |
Correct |
44 ms |
8928 KB |
Output is correct |
19 |
Correct |
44 ms |
8776 KB |
Output is correct |
20 |
Correct |
39 ms |
9396 KB |
Output is correct |
21 |
Correct |
47 ms |
9456 KB |
Output is correct |
22 |
Correct |
44 ms |
9464 KB |
Output is correct |
23 |
Correct |
44 ms |
9436 KB |
Output is correct |
24 |
Correct |
44 ms |
9420 KB |
Output is correct |
25 |
Correct |
43 ms |
9456 KB |
Output is correct |
26 |
Correct |
44 ms |
9432 KB |
Output is correct |
27 |
Correct |
52 ms |
9404 KB |
Output is correct |
28 |
Correct |
44 ms |
9168 KB |
Output is correct |
29 |
Correct |
41 ms |
8596 KB |
Output is correct |
30 |
Correct |
43 ms |
9116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
10236 KB |
Output is correct |
2 |
Correct |
56 ms |
10752 KB |
Output is correct |
3 |
Correct |
56 ms |
10736 KB |
Output is correct |
4 |
Correct |
44 ms |
8876 KB |
Output is correct |
5 |
Correct |
44 ms |
9928 KB |
Output is correct |
6 |
Correct |
44 ms |
9260 KB |
Output is correct |
7 |
Correct |
43 ms |
9460 KB |
Output is correct |
8 |
Correct |
45 ms |
9468 KB |
Output is correct |
9 |
Correct |
49 ms |
9400 KB |
Output is correct |
10 |
Correct |
43 ms |
9132 KB |
Output is correct |
11 |
Correct |
51 ms |
8908 KB |
Output is correct |
12 |
Correct |
43 ms |
8436 KB |
Output is correct |
13 |
Correct |
40 ms |
8316 KB |
Output is correct |
14 |
Correct |
44 ms |
8672 KB |
Output is correct |
15 |
Correct |
44 ms |
9072 KB |
Output is correct |
16 |
Correct |
44 ms |
8948 KB |
Output is correct |
17 |
Correct |
44 ms |
8772 KB |
Output is correct |
18 |
Correct |
43 ms |
8828 KB |
Output is correct |
19 |
Correct |
44 ms |
8928 KB |
Output is correct |
20 |
Correct |
39 ms |
9396 KB |
Output is correct |
21 |
Correct |
39 ms |
9388 KB |
Output is correct |
22 |
Correct |
43 ms |
9380 KB |
Output is correct |
23 |
Correct |
48 ms |
9136 KB |
Output is correct |
24 |
Correct |
44 ms |
9172 KB |
Output is correct |
25 |
Correct |
43 ms |
9392 KB |
Output is correct |
26 |
Correct |
44 ms |
9444 KB |
Output is correct |
27 |
Correct |
44 ms |
9260 KB |
Output is correct |
28 |
Correct |
44 ms |
9372 KB |
Output is correct |
29 |
Correct |
43 ms |
8852 KB |
Output is correct |
30 |
Correct |
41 ms |
9200 KB |
Output is correct |
31 |
Correct |
11 ms |
1992 KB |
Output is correct |
32 |
Correct |
12 ms |
1984 KB |
Output is correct |
33 |
Correct |
12 ms |
2064 KB |
Output is correct |
34 |
Correct |
12 ms |
1996 KB |
Output is correct |
35 |
Correct |
12 ms |
1864 KB |
Output is correct |
36 |
Correct |
12 ms |
2004 KB |
Output is correct |
37 |
Correct |
11 ms |
2008 KB |
Output is correct |
38 |
Correct |
11 ms |
1920 KB |
Output is correct |
39 |
Correct |
11 ms |
2012 KB |
Output is correct |
40 |
Correct |
10 ms |
1912 KB |
Output is correct |
41 |
Correct |
11 ms |
2004 KB |
Output is correct |
42 |
Correct |
12 ms |
2012 KB |
Output is correct |