#include "bits/stdc++.h"
using namespace std;
#include "Joi.h"
const int N = 1e4 + 5;
vector<int> G[N], tt;
int used[N], d[N];
void dfs(int u){
used[u] = 1;
tt.push_back(u);
for(auto x : G[u]){
if(used[x]) continue;
d[x] = d[u] + 1;
dfs(x);
}
}
void Joi(int n, int m, int a[], int b[], long long x, int t) {
for(int i=0;i<m;i++){
G[a[i]].push_back(b[i]);
G[b[i]].push_back(a[i]);
} for(int i=0;i<n;i++){
sort(G[i].begin(), G[i].end());
}
d[0] = 1; dfs(0);
bool ok = 0;
for(int i=0;i<n;i++){
if(d[i] >= 60){
ok = 1;
} d[i] = (d[i] - 1) % 60;
}
if(ok){
for(int i=0;i<n;i++){;
MessageBoard(i, x >> d[i] & 1);
}
} else {
for(int i=0;i<min(n, 60);i++){
MessageBoard(tt[i], x >> i & 1);
} for(int i=60;i<n;i++){
MessageBoard(tt[i], 0);
}
}
}
#include "bits/stdc++.h"
using namespace std;
#include "Ioi.h"
const int N = 1e4 + 5;
int used[N], par[N], d[N];
vector<int> G[N], tt;
void dfs(int u){
used[u] = 1;
tt.push_back(u);
for(auto x : G[u]){
if(used[x]) continue;
d[x] = d[u] + 1,
par[x] = u, dfs(x);
tt.push_back(u);
}
}
long long Ioi(int n, int m, int a[], int b[], int p, int v, int t){
for(int i=0;i<m;i++){
G[a[i]].push_back(b[i]);
G[b[i]].push_back(a[i]);
} for(int i=0;i<n;i++){
sort(G[i].begin(), G[i].end());
}
d[0] = 1; dfs(0);
int r = -1;
for(int i=0;i<n;i++){
if(d[i] >= 60) r = i;
}
auto go = [&](int x){ bool ok = 0;
for(auto v : G[p]){
if(v == x) ok = 1;
} assert(ok);
v = Move(x), p = x;
};
long long x = 0;
if(~r){
if(d[p] >= 60){
for(int j=0;j<60;j++){ d[p] = (d[p] - 1) % 60;
if(v) x |= (1ll << d[p]);
if(p) go(par[p]);
} return x;
} else { tt.clear();
while(p) go(par[p]);
while(r) tt.push_back(r), r = par[r];
for(int i=0;i<60;i++){ d[p] = (d[p] - 1) % 60;
if(v) x |= (1ll << d[p]);
if(!tt.empty()){
go(tt.back());
tt.pop_back();
}
} return x;
}
}
while(p) go(par[p]);
memset(used, 0, sizeof used);
int cnt = 1; used[0] = 1;
assert(!tt[0]);
x |= v;
tt.erase(tt.begin(), tt.begin() + 1);
for(auto u : tt){
go(u);
if(used[u]) continue;
if(v) x |= (1ll << cnt);
used[u] = 1; cnt++;
if(cnt == 60) break;
}
return x;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1136 KB |
Output is correct |
2 |
Correct |
0 ms |
1128 KB |
Output is correct |
3 |
Correct |
2 ms |
1132 KB |
Output is correct |
4 |
Correct |
2 ms |
1000 KB |
Output is correct |
5 |
Correct |
1 ms |
1056 KB |
Output is correct |
6 |
Correct |
1 ms |
1216 KB |
Output is correct |
7 |
Correct |
2 ms |
1200 KB |
Output is correct |
8 |
Correct |
1 ms |
1212 KB |
Output is correct |
9 |
Correct |
2 ms |
1136 KB |
Output is correct |
10 |
Correct |
1 ms |
1132 KB |
Output is correct |
11 |
Correct |
4 ms |
1428 KB |
Output is correct |
12 |
Correct |
1 ms |
1132 KB |
Output is correct |
13 |
Correct |
2 ms |
1144 KB |
Output is correct |
14 |
Correct |
1 ms |
1272 KB |
Output is correct |
15 |
Correct |
2 ms |
1144 KB |
Output is correct |
16 |
Correct |
2 ms |
1144 KB |
Output is correct |
17 |
Correct |
1 ms |
1132 KB |
Output is correct |
18 |
Correct |
1 ms |
1144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
4476 KB |
Output is correct |
2 |
Correct |
22 ms |
4488 KB |
Output is correct |
3 |
Correct |
26 ms |
4540 KB |
Output is correct |
4 |
Correct |
16 ms |
2956 KB |
Output is correct |
5 |
Correct |
16 ms |
3496 KB |
Output is correct |
6 |
Correct |
13 ms |
3408 KB |
Output is correct |
7 |
Correct |
13 ms |
3540 KB |
Output is correct |
8 |
Correct |
11 ms |
3512 KB |
Output is correct |
9 |
Correct |
13 ms |
3504 KB |
Output is correct |
10 |
Correct |
12 ms |
3000 KB |
Output is correct |
11 |
Correct |
11 ms |
2984 KB |
Output is correct |
12 |
Correct |
11 ms |
2832 KB |
Output is correct |
13 |
Correct |
11 ms |
2848 KB |
Output is correct |
14 |
Correct |
11 ms |
2980 KB |
Output is correct |
15 |
Correct |
14 ms |
2984 KB |
Output is correct |
16 |
Correct |
12 ms |
3004 KB |
Output is correct |
17 |
Correct |
12 ms |
2992 KB |
Output is correct |
18 |
Correct |
13 ms |
3012 KB |
Output is correct |
19 |
Correct |
12 ms |
2968 KB |
Output is correct |
20 |
Correct |
10 ms |
3732 KB |
Output is correct |
21 |
Correct |
9 ms |
3628 KB |
Output is correct |
22 |
Correct |
11 ms |
3256 KB |
Output is correct |
23 |
Correct |
12 ms |
3544 KB |
Output is correct |
24 |
Correct |
12 ms |
3500 KB |
Output is correct |
25 |
Correct |
12 ms |
3732 KB |
Output is correct |
26 |
Correct |
12 ms |
3728 KB |
Output is correct |
27 |
Correct |
13 ms |
3656 KB |
Output is correct |
28 |
Correct |
12 ms |
3708 KB |
Output is correct |
29 |
Correct |
11 ms |
3452 KB |
Output is correct |
30 |
Correct |
12 ms |
3556 KB |
Output is correct |
31 |
Correct |
1 ms |
1140 KB |
Output is correct |
32 |
Correct |
1 ms |
1144 KB |
Output is correct |
33 |
Correct |
2 ms |
1212 KB |
Output is correct |
34 |
Correct |
1 ms |
1136 KB |
Output is correct |
35 |
Correct |
1 ms |
1140 KB |
Output is correct |
36 |
Correct |
1 ms |
1136 KB |
Output is correct |
37 |
Correct |
2 ms |
1140 KB |
Output is correct |
38 |
Correct |
0 ms |
1224 KB |
Output is correct |
39 |
Correct |
1 ms |
1136 KB |
Output is correct |
40 |
Correct |
1 ms |
1140 KB |
Output is correct |
41 |
Correct |
1 ms |
1076 KB |
Output is correct |
42 |
Correct |
1 ms |
1140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1004 KB |
Output is correct |
2 |
Correct |
1 ms |
1080 KB |
Output is correct |
3 |
Correct |
2 ms |
1088 KB |
Output is correct |
4 |
Correct |
2 ms |
1496 KB |
Output is correct |
5 |
Correct |
3 ms |
1564 KB |
Output is correct |
6 |
Correct |
2 ms |
1568 KB |
Output is correct |
7 |
Correct |
2 ms |
1568 KB |
Output is correct |
8 |
Correct |
2 ms |
1556 KB |
Output is correct |
9 |
Correct |
12 ms |
4628 KB |
Output is correct |
10 |
Correct |
10 ms |
4524 KB |
Output is correct |
11 |
Correct |
17 ms |
4536 KB |
Output is correct |
12 |
Correct |
1 ms |
1004 KB |
Output is correct |
13 |
Correct |
1 ms |
1012 KB |
Output is correct |
14 |
Correct |
1 ms |
1000 KB |
Output is correct |
15 |
Correct |
1 ms |
1012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
4564 KB |
Output is correct |
2 |
Correct |
20 ms |
4544 KB |
Output is correct |
3 |
Correct |
20 ms |
4476 KB |
Output is correct |
4 |
Correct |
12 ms |
2980 KB |
Output is correct |
5 |
Correct |
12 ms |
4016 KB |
Output is correct |
6 |
Correct |
13 ms |
3512 KB |
Output is correct |
7 |
Correct |
15 ms |
3628 KB |
Output is correct |
8 |
Correct |
12 ms |
3472 KB |
Output is correct |
9 |
Correct |
12 ms |
3496 KB |
Output is correct |
10 |
Correct |
12 ms |
3220 KB |
Output is correct |
11 |
Correct |
13 ms |
3256 KB |
Output is correct |
12 |
Correct |
12 ms |
3036 KB |
Output is correct |
13 |
Partially correct |
11 ms |
2896 KB |
Partially correct |
14 |
Partially correct |
11 ms |
3140 KB |
Partially correct |
15 |
Correct |
15 ms |
3200 KB |
Output is correct |
16 |
Correct |
16 ms |
3196 KB |
Output is correct |
17 |
Correct |
11 ms |
3176 KB |
Output is correct |
18 |
Partially correct |
14 ms |
3192 KB |
Partially correct |
19 |
Partially correct |
14 ms |
3220 KB |
Partially correct |
20 |
Correct |
9 ms |
3940 KB |
Output is correct |
21 |
Correct |
10 ms |
3828 KB |
Output is correct |
22 |
Correct |
16 ms |
3648 KB |
Output is correct |
23 |
Correct |
13 ms |
3548 KB |
Output is correct |
24 |
Correct |
18 ms |
3700 KB |
Output is correct |
25 |
Correct |
12 ms |
3736 KB |
Output is correct |
26 |
Correct |
12 ms |
3748 KB |
Output is correct |
27 |
Correct |
13 ms |
3720 KB |
Output is correct |
28 |
Correct |
13 ms |
3584 KB |
Output is correct |
29 |
Correct |
11 ms |
3440 KB |
Output is correct |
30 |
Correct |
13 ms |
3660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
4472 KB |
Output is correct |
2 |
Correct |
26 ms |
4500 KB |
Output is correct |
3 |
Correct |
24 ms |
4532 KB |
Output is correct |
4 |
Incorrect |
12 ms |
2992 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |