# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
117191 |
2019-06-15T09:28:15 Z |
임유진(#2871) |
Treasure Hunt (CEOI11_tre) |
C++14 |
|
1387 ms |
78800 KB |
#include<stdio.h>
#define MAXN 400010
int n;
int num[MAXN], dep[MAXN], pidx[MAXN][20], pnum[MAXN][20], pdep[MAXN][20];
int bsnum(int x){
int s=0, e=n-1;
while(s<e){
int m=(s+e)/2;
if(x<=num[m]) e=m;
else s=m+1;
}
return s;
}
int bsdep(int d, int idx){
for(int i=19; i>=0; i--)
if(pdep[idx][i]>=d) idx=pidx[idx][i];
return idx;
}
void init(){
n=1;
num[0]=1;
dep[0]=0;
for(int i=0; i<20; i++){
pidx[0][i]=pdep[0][i]=0;
pnum[0][i]=1;
}
}
void path(int a, int s){
num[n]=num[n-1]+s;
pidx[n][0]=bsnum(a);
pdep[n][0]=dep[pidx[n][0]]-num[pidx[n][0]]+a;
pnum[n][0]=a;
dep[n]=pdep[n][0]+s;
for(int i=1; i<20; i++){
pidx[n][i]=pidx[pidx[n][i-1]][i-1];
pdep[n][i]=pdep[pidx[n][i-1]][i-1];
pnum[n][i]=pnum[pidx[n][i-1]][i-1];
}
n++;
}
int dig(int a, int b){
bool c=false;
if(a>b){
int t=a;
a=b;
b=t;
c=true;
}
int aidx=bsnum(a), bidx=bsnum(b);
int adep=dep[aidx]-num[aidx]+a, bdep=dep[bidx]-num[bidx]+b;
int btidx=bidx;
for(int i=19; i>=0; i--){
if(bsdep(pdep[btidx][i], aidx)!=pidx[btidx][i]){
btidx=pidx[btidx][i];
}
}
int d=pdep[btidx][0];
if(btidx==aidx) d=adep;
int idx;
if(adep+1<bdep){
d+=c?(bdep-adep+1)/2:(bdep-adep)/2;
idx=bsdep(d, bidx);
}
else{
d+=c?(adep-bdep)/2:(adep-bdep+1)/2;
idx=bsdep(d, aidx);
}
return num[idx]-dep[idx]+d;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
569 ms |
78800 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1092 ms |
11272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
807 ms |
51068 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1387 ms |
50916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
367 ms |
13980 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
626 ms |
50808 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
960 ms |
50948 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1070 ms |
51016 KB |
Output isn't correct |