이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
//#include "grader.cpp"
#define MAX_COMM 1000006
#define LOG_COMM 20
int curr_comm;
char edg_char[MAX_COMM];
int par[MAX_COMM][LOG_COMM] ,dist[MAX_COMM][LOG_COMM];
int dist_root[MAX_COMM];
void bld_anc(int u ,int p ,int v){
par[u][0] = p;
dist[u][0] = (bool)v;
dist_root[u] = dist_root[p]+(bool)v;
edg_char[u] = (v ? v : edg_char[p]);
for(int i=1; i<LOG_COMM; i++)
if(~par[u][i-1]){
par[u][i] = par[par[u][i-1]][i-1];
dist[u][i] = dist[u][i-1] + dist[par[u][i-1]][i-1];
}
}
void Init(){
curr_comm = 0;
memset(par ,-1 ,sizeof par);
memset(dist ,0 ,sizeof dist);
memset(dist_root ,0 ,sizeof dist_root);
}
void TypeLetter(char L){++curr_comm;
bld_anc(curr_comm ,curr_comm-1 ,L);
}
void UndoCommands(int U){++curr_comm;
bld_anc(curr_comm ,curr_comm-U-1 ,0);
}
char GetLetter(int P){
int u = curr_comm;
P = dist_root[u]-P-1;
for(int i=LOG_COMM-1; ~i; i--)
if(~par[u][i] && dist[u][i] <= P){
P -= dist[u][i];
u = par[u][i];
}
return edg_char[u];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |