#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define st first
#define nd second
#define pb push_back
#define MAX 20005
#define sz(x) ((int)x.size())
#define pw(x) (1LL<<(x))
static int Time;
static int beg[MAX];
static bool Bit[MAX],vis[MAX];
static vector<int> v[MAX];
static void createbits(ll x) {
for(int i=0;i<60;i++) Bit[i]=((x>>i)&1);
}
static void dfs(int node) {
vis[node]=true;
beg[node]=Time++;
MessageBoard(node,Bit[beg[node]%60]);
for(int i:v[node]) {
if(vis[i]) continue ;
dfs(i);
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
createbits(X);
for(int i=0;i<M;i++) {
v[A[i]].pb(B[i]);
v[B[i]].pb(A[i]);
}
dfs(1);
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define st first
#define nd second
#define pb push_back
#define MAX 20005
#define sz(x) ((int) x.size())
#define pw(x) (1LL<<(x))
static int sub[MAX],Par[MAX],beg[MAX];
static int Time,total,V,P;
static ll X;
static vector<int> v[MAX],v2[MAX];
static bool vis[MAX];
static void dfs2(int node) {
total++;
X|=V*pw(beg[node]%60);
for(int i:v2[node]) {
if(total==60) continue ;
V=Move(i);
dfs2(i);
if(total<60) V=Move(node);
}
}
static void solve() {
while(1) {
if(sub[P]>=60) break ;
P=Par[P];
V=Move(P);
}
dfs2(P);
}
static void dfs(int node,int ata) {
vis[node]=true;
sub[node]=1;
beg[node]=Time++;
Par[node]=ata;
if(~ata) v2[ata].pb(node);
for(int i:v[node]) {
if(vis[i]) continue ;
dfs(i,node);
sub[node]+=sub[i];
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for(int i=0;i<M;i++) {
v[A[i]].pb(B[i]);
v[B[i]].pb(A[i]);
}
::P=P;
::V=V;
dfs(1,-1);
solve();
return X;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2276 KB |
Output is correct |
2 |
Correct |
6 ms |
2844 KB |
Output is correct |
3 |
Correct |
6 ms |
2984 KB |
Output is correct |
4 |
Correct |
6 ms |
3056 KB |
Output is correct |
5 |
Correct |
6 ms |
3176 KB |
Output is correct |
6 |
Correct |
6 ms |
3296 KB |
Output is correct |
7 |
Correct |
6 ms |
3296 KB |
Output is correct |
8 |
Correct |
7 ms |
3296 KB |
Output is correct |
9 |
Correct |
7 ms |
3296 KB |
Output is correct |
10 |
Correct |
6 ms |
3296 KB |
Output is correct |
11 |
Correct |
9 ms |
3512 KB |
Output is correct |
12 |
Correct |
6 ms |
3728 KB |
Output is correct |
13 |
Correct |
5 ms |
3728 KB |
Output is correct |
14 |
Correct |
6 ms |
3728 KB |
Output is correct |
15 |
Correct |
6 ms |
3728 KB |
Output is correct |
16 |
Correct |
7 ms |
3728 KB |
Output is correct |
17 |
Correct |
10 ms |
3728 KB |
Output is correct |
18 |
Correct |
8 ms |
3728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
5700 KB |
Output is correct |
2 |
Correct |
37 ms |
6664 KB |
Output is correct |
3 |
Correct |
44 ms |
6664 KB |
Output is correct |
4 |
Correct |
26 ms |
6664 KB |
Output is correct |
5 |
Correct |
25 ms |
6664 KB |
Output is correct |
6 |
Correct |
26 ms |
6664 KB |
Output is correct |
7 |
Correct |
22 ms |
6664 KB |
Output is correct |
8 |
Correct |
31 ms |
6664 KB |
Output is correct |
9 |
Correct |
25 ms |
6664 KB |
Output is correct |
10 |
Correct |
27 ms |
6664 KB |
Output is correct |
11 |
Correct |
19 ms |
6664 KB |
Output is correct |
12 |
Correct |
19 ms |
6664 KB |
Output is correct |
13 |
Correct |
24 ms |
6664 KB |
Output is correct |
14 |
Correct |
25 ms |
6664 KB |
Output is correct |
15 |
Correct |
26 ms |
6664 KB |
Output is correct |
16 |
Correct |
26 ms |
6664 KB |
Output is correct |
17 |
Correct |
23 ms |
6664 KB |
Output is correct |
18 |
Correct |
24 ms |
6664 KB |
Output is correct |
19 |
Correct |
27 ms |
6664 KB |
Output is correct |
20 |
Correct |
24 ms |
6664 KB |
Output is correct |
21 |
Correct |
23 ms |
6664 KB |
Output is correct |
22 |
Correct |
33 ms |
6664 KB |
Output is correct |
23 |
Correct |
23 ms |
6664 KB |
Output is correct |
24 |
Correct |
23 ms |
6664 KB |
Output is correct |
25 |
Correct |
24 ms |
6664 KB |
Output is correct |
26 |
Correct |
23 ms |
6664 KB |
Output is correct |
27 |
Correct |
27 ms |
6664 KB |
Output is correct |
28 |
Correct |
25 ms |
6664 KB |
Output is correct |
29 |
Correct |
19 ms |
6664 KB |
Output is correct |
30 |
Correct |
26 ms |
6664 KB |
Output is correct |
31 |
Correct |
6 ms |
6664 KB |
Output is correct |
32 |
Correct |
6 ms |
6664 KB |
Output is correct |
33 |
Correct |
6 ms |
6664 KB |
Output is correct |
34 |
Correct |
6 ms |
6664 KB |
Output is correct |
35 |
Correct |
7 ms |
6664 KB |
Output is correct |
36 |
Correct |
6 ms |
6664 KB |
Output is correct |
37 |
Correct |
6 ms |
6664 KB |
Output is correct |
38 |
Correct |
7 ms |
6664 KB |
Output is correct |
39 |
Correct |
6 ms |
6664 KB |
Output is correct |
40 |
Correct |
5 ms |
6664 KB |
Output is correct |
41 |
Correct |
7 ms |
6664 KB |
Output is correct |
42 |
Correct |
7 ms |
6664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
6664 KB |
Output is correct |
2 |
Correct |
6 ms |
6664 KB |
Output is correct |
3 |
Correct |
6 ms |
6664 KB |
Output is correct |
4 |
Correct |
10 ms |
6664 KB |
Output is correct |
5 |
Correct |
9 ms |
6664 KB |
Output is correct |
6 |
Correct |
10 ms |
6664 KB |
Output is correct |
7 |
Correct |
8 ms |
6664 KB |
Output is correct |
8 |
Correct |
11 ms |
6664 KB |
Output is correct |
9 |
Correct |
22 ms |
6664 KB |
Output is correct |
10 |
Correct |
27 ms |
6664 KB |
Output is correct |
11 |
Correct |
30 ms |
6664 KB |
Output is correct |
12 |
Correct |
7 ms |
6664 KB |
Output is correct |
13 |
Correct |
6 ms |
6664 KB |
Output is correct |
14 |
Correct |
8 ms |
6664 KB |
Output is correct |
15 |
Correct |
5 ms |
6664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
6664 KB |
Output is correct |
2 |
Correct |
44 ms |
6664 KB |
Output is correct |
3 |
Correct |
51 ms |
6664 KB |
Output is correct |
4 |
Correct |
36 ms |
6664 KB |
Output is correct |
5 |
Partially correct |
30 ms |
6664 KB |
Partially correct |
6 |
Correct |
25 ms |
6664 KB |
Output is correct |
7 |
Correct |
30 ms |
6664 KB |
Output is correct |
8 |
Correct |
20 ms |
6664 KB |
Output is correct |
9 |
Correct |
25 ms |
6664 KB |
Output is correct |
10 |
Correct |
40 ms |
6664 KB |
Output is correct |
11 |
Correct |
23 ms |
6664 KB |
Output is correct |
12 |
Correct |
33 ms |
6664 KB |
Output is correct |
13 |
Correct |
20 ms |
6664 KB |
Output is correct |
14 |
Correct |
24 ms |
6664 KB |
Output is correct |
15 |
Correct |
20 ms |
6664 KB |
Output is correct |
16 |
Correct |
24 ms |
6664 KB |
Output is correct |
17 |
Correct |
25 ms |
6664 KB |
Output is correct |
18 |
Partially correct |
22 ms |
6664 KB |
Partially correct |
19 |
Correct |
28 ms |
6664 KB |
Output is correct |
20 |
Correct |
17 ms |
6664 KB |
Output is correct |
21 |
Correct |
26 ms |
6664 KB |
Output is correct |
22 |
Correct |
28 ms |
6664 KB |
Output is correct |
23 |
Correct |
22 ms |
6664 KB |
Output is correct |
24 |
Correct |
26 ms |
6664 KB |
Output is correct |
25 |
Correct |
22 ms |
6664 KB |
Output is correct |
26 |
Correct |
30 ms |
6664 KB |
Output is correct |
27 |
Correct |
28 ms |
6664 KB |
Output is correct |
28 |
Correct |
33 ms |
6664 KB |
Output is correct |
29 |
Correct |
36 ms |
6664 KB |
Output is correct |
30 |
Correct |
28 ms |
6664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
6688 KB |
Output is correct |
2 |
Correct |
34 ms |
6712 KB |
Output is correct |
3 |
Correct |
34 ms |
6712 KB |
Output is correct |
4 |
Correct |
23 ms |
6712 KB |
Output is correct |
5 |
Incorrect |
24 ms |
6712 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |