제출 #31197

#제출 시각아이디문제언어결과실행 시간메모리
31197pasa3232크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
699 ms128132 KiB
#include<bits/stdc++.h>
using namespace std;

int now, A[1000010], d[30][1000010], lev[1000010];
char L[1000010];

char last;

void Init() {
    for(int i=0; i<30; i++) for(int j=0; j<1000010; j++) d[i][j]=-1;
}

void TypeLetter(char La) {
    A[++now]=now;
    lev[now]=lev[A[now-1]]+1;
    L[now]=La;
    d[0][now]=A[now-1];
    for(int i=1; d[i-1][d[i-1][now]]!=-1; i++) d[i][now]=d[i-1][d[i-1][now]];
}

void UndoCommands(int U) {
    A[++now]=A[now-U-1];
}

char GetLetter(int P) {
    int b=P;
    b=lev[A[now]]-b-1;
    int rev=A[now];
    while(b){
        int i, num;
        for(i=0, num=1; num<=b; i++, num*=2);
        i--;
        b-=(num/2);
        rev=d[i][rev];
    }
    return L[rev];

}

컴파일 시 표준 에러 (stderr) 메시지

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:14:17: warning: operation on 'now' may be undefined [-Wsequence-point]
     A[++now]=now;
                 ^
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:22:24: warning: operation on 'now' may be undefined [-Wsequence-point]
     A[++now]=A[now-U-1];
                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...