| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 68019 | naderjemel | 낙하산 고리들 (IOI12_rings) | C++14 | 0 ms | 0 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <grader.cpp>    
#include <bits/stdc++.h>
    using namespace std;
    const int LOG = 21;
    struct node
    {
    	char c; int s;
    	node *anc[LOG];
    	node(){
    		for(int i=0;i<LOG;i++) anc[i] = NULL;
    		s=0;
    	}
    }*tree [1000005];
     
    int id;
    void Init(){
    	id=1;
    	tree[0] = new node();
     
    }
    void TypeLetter(char L) {
    	int n=id++;
    	tree[n] = new node();
    	tree[n]->s = tree[n-1]->s+1;
    	tree[n]->c = L;
    	tree[n]->anc[0]=tree[n-1];
    	for(int i=1;i<LOG;i++) tree[n]->anc[i] = (tree[n]->anc[i-1]) ? (tree[n]->anc[i-1])->anc[i-1] : NULL; 
    }
     
    void UndoCommands(int U) {
    	int ret=id-1-U;
    	int n=id++;
    	tree[n]=tree[ret];
    }
     
     
    char GetLetter(int P) {
    	int n=id-1;
    	node *h = new node();
    	h=tree[n];
    	int up=tree[n]->s - 1 - P;
    	for(int i=LOG-1;i>=0;i--){
    		if(up - (1<<i) >= 0){
    			up-=(1<<i);
    			h=h->anc[i];
    		}
    	}
    	return h->c;
    }
