// ~ Be Name Khoda ~
#include "Joi.h"
#include<bits/stdc++.h>
//#pragma GCC optimize ("Ofast")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,O3")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn5 = 1e5 + 10;
static bool good[maxn5], mark[maxn5];
static int num = 0, bit[maxn5], root, h[maxn5], par[maxn5];
static vector <int> adj[maxn5], have[maxn5];
static void dfs(int v){
mark[v] = true;
num++;
if(num <= 60){
bit[v] = num - 1;
good[v] = true;
}
for(auto u : adj[v]) if(!mark[u]){
mark[u] = v;
par[u] = v;
dfs(u);
}
}
static void dfs2(int v, int par){
have[root].pb(bit[v]);
for(auto u : adj[v]) if(u != par && good[u])
dfs2(u, v);
}
static void dfs3(int v, int par){
if(!good[v]){
bit[v] = have[root][int(have[root].size()) - ((h[v] - 1) % int(have[root].size())) - 1];
}
for(auto u : adj[v]) if(u != par && !good[u]){
h[u] = h[v] + 1;
dfs3(u, v);
}
}
void Joi(int n, int m, int A[], int B[], ll X, int T){
for(int i = 0; i < m; i++){
adj[A[i]].pb(B[i]);
adj[B[i]].pb(A[i]);
}
par[0] = -1;
dfs(0);
for(int i = 0; i < n; i++)
adj[i].clear();
for(int i = 1; i < n; i++){
adj[i].pb(par[i]);
adj[par[i]].pb(i);
}
for(int i = 0; i < n; i++) if(good[i]){
root = i;
dfs2(i, -1);
}
for(int i = 0; i < n; i++) if(good[i]){
root = i;
dfs3(i, -1);
}
for(int i = 0; i < n; i++)
MessageBoard(i, (X >> (bit[i])) & 1);
return;
}
// ~ Be Name Khoda ~
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn5 = 1e5 + 10;
static bool good[maxn5], mark[maxn5];
static int num = 0, bit[maxn5], done = 0, root;
static int par[maxn5], ans[maxn5], h[maxn5];
static vector <int> adj[maxn5], have[maxn5];
static ll x;
static void dfs(int v){
mark[v] = true;
num++;
if(num <= 60){
bit[v] = num - 1;
good[v] = true;
}
for(auto u : adj[v]) if(!mark[u]){
mark[u] = v;
par[u] = v;
dfs(u);
}
}
static void dfs2(int v, int par){
have[root].pb(bit[v]);
for(auto u : adj[v]) if(u != par && good[u])
dfs2(u, v);
}
static void dfs3(int v){
if(!good[v]){
bit[v] = have[root][int(have[root].size()) - ((h[v] - 1) % int(have[root].size())) - 1];
}
for(auto u : adj[v]) if(u != par[v] && !good[u]){
h[u] = h[v] + 1;
par[u] = v;
dfs3(u);
}
}
static void dfs4(int v){
if(done == 60)
return;
done++;
if(ans[v])
x += (1LL << bit[v]);
for(auto u : adj[v]) if(u != par[v] && good[u] && done < 60){
par[u] = v;
ans[u] = Move(u);
dfs4(u);
}
if(done < 60 && par[v] != -1)
Move(par[v]);
}
ll Ioi(int n, int m, int A[], int B[], int p, int V, int T) {
for(int i = 0; i < m; i++){
adj[A[i]].pb(B[i]);
adj[B[i]].pb(A[i]);
}
par[0] = -1;
dfs(0);
for(int i = 0; i < n; i++)
adj[i].clear();
for(int i = 1; i < n; i++){
adj[i].pb(par[i]);
adj[par[i]].pb(i);
}
for(int i = 0; i < n; i++) if(good[i]){
root = i;
dfs2(i, -1);
}
for(int i = 0; i < n; i++) if(good[i]){
par[i] = -1;
root = i;
dfs3(i);
}
ans[p] = V;
done = 0;
while(!good[p] && done < 60){
if(ans[p])
x += (1LL << bit[p]);
done++;
p = par[p];
ans[p] = Move(p);
}
if(done == 60)
return x;
par[p] = -1;
dfs4(p);
return x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
10128 KB |
Output is correct |
2 |
Correct |
6 ms |
10136 KB |
Output is correct |
3 |
Correct |
6 ms |
10132 KB |
Output is correct |
4 |
Correct |
6 ms |
10008 KB |
Output is correct |
5 |
Correct |
6 ms |
10128 KB |
Output is correct |
6 |
Correct |
6 ms |
10136 KB |
Output is correct |
7 |
Correct |
6 ms |
10268 KB |
Output is correct |
8 |
Correct |
6 ms |
10268 KB |
Output is correct |
9 |
Correct |
6 ms |
10260 KB |
Output is correct |
10 |
Correct |
7 ms |
10136 KB |
Output is correct |
11 |
Correct |
10 ms |
10432 KB |
Output is correct |
12 |
Correct |
6 ms |
10008 KB |
Output is correct |
13 |
Correct |
6 ms |
10204 KB |
Output is correct |
14 |
Correct |
7 ms |
10268 KB |
Output is correct |
15 |
Correct |
6 ms |
10268 KB |
Output is correct |
16 |
Correct |
6 ms |
10140 KB |
Output is correct |
17 |
Correct |
6 ms |
10260 KB |
Output is correct |
18 |
Correct |
6 ms |
10128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
13724 KB |
Output is correct |
2 |
Correct |
32 ms |
13780 KB |
Output is correct |
3 |
Correct |
26 ms |
13676 KB |
Output is correct |
4 |
Correct |
18 ms |
12084 KB |
Output is correct |
5 |
Correct |
18 ms |
12584 KB |
Output is correct |
6 |
Correct |
20 ms |
12320 KB |
Output is correct |
7 |
Correct |
19 ms |
12340 KB |
Output is correct |
8 |
Correct |
17 ms |
12528 KB |
Output is correct |
9 |
Correct |
18 ms |
12592 KB |
Output is correct |
10 |
Correct |
18 ms |
12092 KB |
Output is correct |
11 |
Correct |
17 ms |
12044 KB |
Output is correct |
12 |
Correct |
17 ms |
11828 KB |
Output is correct |
13 |
Correct |
16 ms |
11860 KB |
Output is correct |
14 |
Correct |
17 ms |
12024 KB |
Output is correct |
15 |
Correct |
18 ms |
12048 KB |
Output is correct |
16 |
Correct |
19 ms |
12080 KB |
Output is correct |
17 |
Correct |
18 ms |
12024 KB |
Output is correct |
18 |
Correct |
18 ms |
11980 KB |
Output is correct |
19 |
Correct |
19 ms |
12084 KB |
Output is correct |
20 |
Correct |
15 ms |
12556 KB |
Output is correct |
21 |
Correct |
14 ms |
12636 KB |
Output is correct |
22 |
Correct |
18 ms |
12284 KB |
Output is correct |
23 |
Correct |
18 ms |
12596 KB |
Output is correct |
24 |
Correct |
17 ms |
12400 KB |
Output is correct |
25 |
Correct |
17 ms |
12344 KB |
Output is correct |
26 |
Correct |
18 ms |
12592 KB |
Output is correct |
27 |
Correct |
18 ms |
12584 KB |
Output is correct |
28 |
Correct |
17 ms |
12536 KB |
Output is correct |
29 |
Correct |
17 ms |
12312 KB |
Output is correct |
30 |
Correct |
17 ms |
12252 KB |
Output is correct |
31 |
Correct |
6 ms |
10128 KB |
Output is correct |
32 |
Correct |
6 ms |
10132 KB |
Output is correct |
33 |
Correct |
6 ms |
10156 KB |
Output is correct |
34 |
Correct |
6 ms |
10136 KB |
Output is correct |
35 |
Correct |
6 ms |
10008 KB |
Output is correct |
36 |
Correct |
6 ms |
10000 KB |
Output is correct |
37 |
Correct |
6 ms |
10008 KB |
Output is correct |
38 |
Correct |
6 ms |
10184 KB |
Output is correct |
39 |
Correct |
6 ms |
10128 KB |
Output is correct |
40 |
Correct |
6 ms |
10072 KB |
Output is correct |
41 |
Correct |
6 ms |
10000 KB |
Output is correct |
42 |
Correct |
6 ms |
10000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
10136 KB |
Output is correct |
2 |
Correct |
6 ms |
10008 KB |
Output is correct |
3 |
Correct |
6 ms |
10000 KB |
Output is correct |
4 |
Correct |
7 ms |
10532 KB |
Output is correct |
5 |
Correct |
7 ms |
10628 KB |
Output is correct |
6 |
Correct |
7 ms |
10560 KB |
Output is correct |
7 |
Correct |
7 ms |
10560 KB |
Output is correct |
8 |
Correct |
7 ms |
10636 KB |
Output is correct |
9 |
Correct |
15 ms |
13176 KB |
Output is correct |
10 |
Correct |
15 ms |
13116 KB |
Output is correct |
11 |
Correct |
15 ms |
13340 KB |
Output is correct |
12 |
Correct |
5 ms |
10000 KB |
Output is correct |
13 |
Correct |
6 ms |
10088 KB |
Output is correct |
14 |
Correct |
5 ms |
10008 KB |
Output is correct |
15 |
Correct |
6 ms |
10008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
13708 KB |
Output is correct |
2 |
Correct |
27 ms |
13704 KB |
Output is correct |
3 |
Correct |
26 ms |
13756 KB |
Output is correct |
4 |
Correct |
17 ms |
12080 KB |
Output is correct |
5 |
Correct |
18 ms |
12836 KB |
Output is correct |
6 |
Correct |
17 ms |
12536 KB |
Output is correct |
7 |
Correct |
18 ms |
12524 KB |
Output is correct |
8 |
Correct |
18 ms |
12264 KB |
Output is correct |
9 |
Correct |
19 ms |
12344 KB |
Output is correct |
10 |
Correct |
18 ms |
12072 KB |
Output is correct |
11 |
Correct |
17 ms |
12112 KB |
Output is correct |
12 |
Correct |
15 ms |
11800 KB |
Output is correct |
13 |
Correct |
16 ms |
11808 KB |
Output is correct |
14 |
Correct |
16 ms |
11816 KB |
Output is correct |
15 |
Correct |
18 ms |
12068 KB |
Output is correct |
16 |
Correct |
18 ms |
12080 KB |
Output is correct |
17 |
Correct |
17 ms |
12084 KB |
Output is correct |
18 |
Correct |
17 ms |
11996 KB |
Output is correct |
19 |
Correct |
17 ms |
12084 KB |
Output is correct |
20 |
Correct |
15 ms |
12544 KB |
Output is correct |
21 |
Correct |
14 ms |
12524 KB |
Output is correct |
22 |
Correct |
18 ms |
12444 KB |
Output is correct |
23 |
Correct |
17 ms |
12324 KB |
Output is correct |
24 |
Correct |
20 ms |
12324 KB |
Output is correct |
25 |
Correct |
18 ms |
12576 KB |
Output is correct |
26 |
Correct |
17 ms |
12516 KB |
Output is correct |
27 |
Correct |
18 ms |
12600 KB |
Output is correct |
28 |
Correct |
18 ms |
12268 KB |
Output is correct |
29 |
Correct |
16 ms |
12232 KB |
Output is correct |
30 |
Correct |
20 ms |
12236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
13712 KB |
Output is correct |
2 |
Correct |
26 ms |
13776 KB |
Output is correct |
3 |
Correct |
25 ms |
13756 KB |
Output is correct |
4 |
Correct |
17 ms |
11992 KB |
Output is correct |
5 |
Correct |
18 ms |
13108 KB |
Output is correct |
6 |
Correct |
18 ms |
12320 KB |
Output is correct |
7 |
Correct |
23 ms |
12332 KB |
Output is correct |
8 |
Correct |
18 ms |
12540 KB |
Output is correct |
9 |
Correct |
17 ms |
12332 KB |
Output is correct |
10 |
Correct |
17 ms |
12036 KB |
Output is correct |
11 |
Correct |
18 ms |
11988 KB |
Output is correct |
12 |
Correct |
15 ms |
11756 KB |
Output is correct |
13 |
Correct |
15 ms |
11808 KB |
Output is correct |
14 |
Correct |
17 ms |
12024 KB |
Output is correct |
15 |
Correct |
17 ms |
12084 KB |
Output is correct |
16 |
Correct |
18 ms |
12084 KB |
Output is correct |
17 |
Correct |
18 ms |
12088 KB |
Output is correct |
18 |
Correct |
17 ms |
12008 KB |
Output is correct |
19 |
Correct |
17 ms |
12080 KB |
Output is correct |
20 |
Correct |
14 ms |
12592 KB |
Output is correct |
21 |
Correct |
14 ms |
12604 KB |
Output is correct |
22 |
Correct |
18 ms |
12320 KB |
Output is correct |
23 |
Correct |
17 ms |
12336 KB |
Output is correct |
24 |
Correct |
17 ms |
12336 KB |
Output is correct |
25 |
Correct |
17 ms |
12380 KB |
Output is correct |
26 |
Correct |
18 ms |
12200 KB |
Output is correct |
27 |
Correct |
18 ms |
12600 KB |
Output is correct |
28 |
Correct |
18 ms |
12600 KB |
Output is correct |
29 |
Correct |
17 ms |
12264 KB |
Output is correct |
30 |
Correct |
16 ms |
12304 KB |
Output is correct |
31 |
Correct |
6 ms |
10008 KB |
Output is correct |
32 |
Correct |
6 ms |
10008 KB |
Output is correct |
33 |
Correct |
6 ms |
10264 KB |
Output is correct |
34 |
Correct |
5 ms |
10236 KB |
Output is correct |
35 |
Correct |
6 ms |
10008 KB |
Output is correct |
36 |
Correct |
6 ms |
10068 KB |
Output is correct |
37 |
Correct |
6 ms |
10000 KB |
Output is correct |
38 |
Correct |
6 ms |
10176 KB |
Output is correct |
39 |
Correct |
5 ms |
10000 KB |
Output is correct |
40 |
Correct |
6 ms |
10008 KB |
Output is correct |
41 |
Correct |
5 ms |
10124 KB |
Output is correct |
42 |
Correct |
6 ms |
10004 KB |
Output is correct |