# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
117184 |
2019-06-15T08:33:35 Z |
임유진(#2871) |
Treasure Hunt (CEOI11_tre) |
C++14 |
|
1664 ms |
78756 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<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 |
10 ms |
380 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 |
579 ms |
78756 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
990 ms |
11464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
751 ms |
50984 KB |
Output is correct |
2 |
Incorrect |
730 ms |
6780 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1664 ms |
50972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
364 ms |
14012 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
629 ms |
50936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
991 ms |
50936 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1008 ms |
50884 KB |
Output isn't correct |