#include "Joi.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
namespace{
int n, m;
vector<int> link[10002];
int depth[10002], par[10002], maxDepth[10002];
bool visited[10002];
bool existPath;
int idx[10002], idxCnt;
void dfs(int x, int dp=0){
visited[x] = 1;
depth[x] = dp;
vector<int> newLink;
for(auto y: link[x]){
if(visited[y]) continue;
newLink.push_back(y);
par[y] = x;
dfs(y, dp+1);
maxDepth[x] = max(maxDepth[x], maxDepth[y]+1);
}
link[x].swap(newLink);
}
void dfs2(int x){
visited[x] = 1;
if(idxCnt < 60) idx[x] = idxCnt++;
for(auto y: link[x]){
if(visited[y]) continue;
dfs2(y);
}
}
}
void Joi(int N, int M, int A[], int B[], ll X, int T) {
n = N, m = M;
for(int i=0; i<m; i++){
link[A[i]].push_back(B[i]);
link[B[i]].push_back(A[i]);
}
dfs(0);
existPath = (maxDepth[0] >= 59);
if(existPath){
for(int i=0; i<n; i++){
MessageBoard(i, (X>>(depth[i]%60))&1);
}
}
else{
memset(visited, 0, sizeof(visited));
dfs2(0);
for(int i=0; i<n; i++){
MessageBoard(i, (X>>idx[i])&1);
}
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace{
int n, m;
vector<int> link[10002];
int depth[10002], par[10002], maxDepth[10002];
bool visited[10002];
bool existPath;
int idx[10002], idxCnt;
vector<int> runway;
void dfs(int x, int dp=0){
visited[x] = 1;
depth[x] = dp;
vector<int> newLink;
for(auto y: link[x]){
if(visited[y]) continue;
newLink.push_back(y);
par[y] = x;
dfs(y, dp+1);
maxDepth[x] = max(maxDepth[x], maxDepth[y]+1);
}
link[x].swap(newLink);
}
void dfs2(int x){
visited[x] = 1;
if(idxCnt < 60) idx[x] = idxCnt++;
runway.push_back(x);
for(auto y: link[x]){
if(visited[y]) continue;
dfs2(y);
if(idxCnt == 60) break;
runway.push_back(x);
}
}
}
ll Ioi(int N, int M, int A[], int B[], int P, int V, int T){
n = N, m = M;
for(int i=0; i<m; i++){
link[A[i]].push_back(B[i]);
link[B[i]].push_back(A[i]);
}
dfs(0);
existPath = (maxDepth[0] >= 59);
if(existPath){ /// �ö� �������� ��
int x = P;
ll ans = 0;
if(depth[x] >= 59){ /// �ö� ��
for(int cnt=0; cnt<59; cnt++){
if(V) ans += (1LL << (depth[x] % 60));
V = Move(x = par[x]);
}
if(V) ans += (1LL << (depth[x] % 60));
return ans;
}
while(x){
V = Move(x = par[x]);
}
for(int cnt=0; cnt<59; cnt++){
if(V) ans += (1LL << cnt);
int nxt = -1;
for(auto y: link[x]){
if(cnt + maxDepth[y] >= 58){
nxt = y;
break;
}
}
assert(nxt != -1);
V = Move(x = nxt);
}
if(V) ans += (1LL << 59);
return ans;
}
/// ���� ��Ʈ���� �ö�
int x = P;
ll ans = 0;
while(x) V = Move(x = par[x]);
memset(visited, 0, sizeof(visited));
dfs2(x);
if(V) ans |= (1LL << idx[x]);
for(auto nxt: runway){
if(nxt == x) continue;
V = Move(x = nxt);
if(V) ans |= (1LL << idx[x]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1032 KB |
Output is correct |
2 |
Correct |
2 ms |
1108 KB |
Output is correct |
3 |
Correct |
2 ms |
1288 KB |
Output is correct |
4 |
Correct |
0 ms |
1028 KB |
Output is correct |
5 |
Correct |
1 ms |
1048 KB |
Output is correct |
6 |
Correct |
1 ms |
1288 KB |
Output is correct |
7 |
Correct |
2 ms |
1256 KB |
Output is correct |
8 |
Correct |
1 ms |
1296 KB |
Output is correct |
9 |
Correct |
2 ms |
1160 KB |
Output is correct |
10 |
Correct |
1 ms |
1024 KB |
Output is correct |
11 |
Correct |
3 ms |
1488 KB |
Output is correct |
12 |
Correct |
2 ms |
1032 KB |
Output is correct |
13 |
Correct |
2 ms |
1168 KB |
Output is correct |
14 |
Correct |
2 ms |
1288 KB |
Output is correct |
15 |
Correct |
1 ms |
1296 KB |
Output is correct |
16 |
Correct |
2 ms |
1120 KB |
Output is correct |
17 |
Correct |
1 ms |
1248 KB |
Output is correct |
18 |
Correct |
2 ms |
1288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
5200 KB |
Output is correct |
2 |
Correct |
23 ms |
5236 KB |
Output is correct |
3 |
Correct |
23 ms |
5196 KB |
Output is correct |
4 |
Correct |
15 ms |
2772 KB |
Output is correct |
5 |
Correct |
14 ms |
4372 KB |
Output is correct |
6 |
Correct |
12 ms |
3888 KB |
Output is correct |
7 |
Correct |
12 ms |
3888 KB |
Output is correct |
8 |
Correct |
15 ms |
4132 KB |
Output is correct |
9 |
Correct |
13 ms |
4140 KB |
Output is correct |
10 |
Correct |
13 ms |
3132 KB |
Output is correct |
11 |
Correct |
12 ms |
3252 KB |
Output is correct |
12 |
Correct |
12 ms |
2812 KB |
Output is correct |
13 |
Correct |
12 ms |
2764 KB |
Output is correct |
14 |
Correct |
12 ms |
2824 KB |
Output is correct |
15 |
Correct |
16 ms |
2856 KB |
Output is correct |
16 |
Correct |
12 ms |
2996 KB |
Output is correct |
17 |
Correct |
14 ms |
2908 KB |
Output is correct |
18 |
Correct |
12 ms |
2984 KB |
Output is correct |
19 |
Correct |
12 ms |
2956 KB |
Output is correct |
20 |
Correct |
13 ms |
4104 KB |
Output is correct |
21 |
Correct |
11 ms |
4092 KB |
Output is correct |
22 |
Correct |
15 ms |
3636 KB |
Output is correct |
23 |
Correct |
14 ms |
3888 KB |
Output is correct |
24 |
Correct |
12 ms |
3628 KB |
Output is correct |
25 |
Correct |
13 ms |
3888 KB |
Output is correct |
26 |
Correct |
13 ms |
4096 KB |
Output is correct |
27 |
Correct |
14 ms |
4140 KB |
Output is correct |
28 |
Correct |
14 ms |
4084 KB |
Output is correct |
29 |
Correct |
15 ms |
3636 KB |
Output is correct |
30 |
Correct |
15 ms |
3612 KB |
Output is correct |
31 |
Correct |
2 ms |
1032 KB |
Output is correct |
32 |
Correct |
1 ms |
1164 KB |
Output is correct |
33 |
Correct |
2 ms |
1292 KB |
Output is correct |
34 |
Correct |
2 ms |
1124 KB |
Output is correct |
35 |
Correct |
2 ms |
1028 KB |
Output is correct |
36 |
Correct |
2 ms |
1028 KB |
Output is correct |
37 |
Correct |
2 ms |
1036 KB |
Output is correct |
38 |
Correct |
1 ms |
1036 KB |
Output is correct |
39 |
Correct |
2 ms |
1036 KB |
Output is correct |
40 |
Correct |
1 ms |
1096 KB |
Output is correct |
41 |
Correct |
1 ms |
1028 KB |
Output is correct |
42 |
Correct |
1 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1104 KB |
Output is correct |
2 |
Correct |
1 ms |
1028 KB |
Output is correct |
3 |
Correct |
2 ms |
1028 KB |
Output is correct |
4 |
Correct |
3 ms |
1844 KB |
Output is correct |
5 |
Correct |
2 ms |
1836 KB |
Output is correct |
6 |
Correct |
3 ms |
1932 KB |
Output is correct |
7 |
Correct |
2 ms |
1932 KB |
Output is correct |
8 |
Correct |
3 ms |
1844 KB |
Output is correct |
9 |
Correct |
11 ms |
5928 KB |
Output is correct |
10 |
Correct |
12 ms |
5928 KB |
Output is correct |
11 |
Correct |
13 ms |
5900 KB |
Output is correct |
12 |
Correct |
1 ms |
1028 KB |
Output is correct |
13 |
Correct |
2 ms |
1028 KB |
Output is correct |
14 |
Correct |
1 ms |
1028 KB |
Output is correct |
15 |
Correct |
1 ms |
1008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
5656 KB |
Output is correct |
2 |
Correct |
20 ms |
5552 KB |
Output is correct |
3 |
Correct |
22 ms |
5660 KB |
Output is correct |
4 |
Correct |
13 ms |
3036 KB |
Output is correct |
5 |
Correct |
15 ms |
5140 KB |
Output is correct |
6 |
Correct |
19 ms |
4104 KB |
Output is correct |
7 |
Correct |
13 ms |
3892 KB |
Output is correct |
8 |
Correct |
12 ms |
3368 KB |
Output is correct |
9 |
Correct |
12 ms |
3624 KB |
Output is correct |
10 |
Correct |
12 ms |
3264 KB |
Output is correct |
11 |
Correct |
12 ms |
3256 KB |
Output is correct |
12 |
Correct |
12 ms |
2840 KB |
Output is correct |
13 |
Partially correct |
11 ms |
2832 KB |
Partially correct |
14 |
Partially correct |
12 ms |
2844 KB |
Partially correct |
15 |
Correct |
13 ms |
2928 KB |
Output is correct |
16 |
Correct |
12 ms |
2956 KB |
Output is correct |
17 |
Correct |
13 ms |
3112 KB |
Output is correct |
18 |
Partially correct |
13 ms |
2984 KB |
Partially correct |
19 |
Partially correct |
12 ms |
3068 KB |
Partially correct |
20 |
Correct |
12 ms |
4100 KB |
Output is correct |
21 |
Correct |
10 ms |
4192 KB |
Output is correct |
22 |
Correct |
13 ms |
3848 KB |
Output is correct |
23 |
Correct |
13 ms |
3888 KB |
Output is correct |
24 |
Correct |
13 ms |
3848 KB |
Output is correct |
25 |
Correct |
13 ms |
4080 KB |
Output is correct |
26 |
Correct |
14 ms |
3880 KB |
Output is correct |
27 |
Correct |
15 ms |
4112 KB |
Output is correct |
28 |
Correct |
12 ms |
3628 KB |
Output is correct |
29 |
Correct |
15 ms |
3708 KB |
Output is correct |
30 |
Correct |
12 ms |
3840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
5584 KB |
Output is correct |
2 |
Correct |
22 ms |
5628 KB |
Output is correct |
3 |
Correct |
22 ms |
5652 KB |
Output is correct |
4 |
Correct |
12 ms |
2980 KB |
Output is correct |
5 |
Correct |
14 ms |
5444 KB |
Output is correct |
6 |
Correct |
14 ms |
3956 KB |
Output is correct |
7 |
Correct |
12 ms |
3548 KB |
Output is correct |
8 |
Correct |
13 ms |
4116 KB |
Output is correct |
9 |
Correct |
13 ms |
3884 KB |
Output is correct |
10 |
Correct |
12 ms |
3124 KB |
Output is correct |
11 |
Correct |
12 ms |
3212 KB |
Output is correct |
12 |
Correct |
12 ms |
2844 KB |
Output is correct |
13 |
Incorrect |
12 ms |
2860 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |