이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define for0(i,n) for(int i=0;i<=(int)n;i++)
#define forn(i,n) for(int i=n;i>=1;i--)
#define fo(i,x,y) for(int i=x;i<=(int)y;i++)
#define fr(i,x,y) for(int i=x;i>=(int)y;i--)
#define pb push_back
#define mp make_pair
#define LL long long
const LL Mod=1000*1000*1000+7;
char last;
int OP_NOW;
int letter_par[1000002];
int up[1000002][30];
int height[1000002];
void Init() {}
void TypeLetter(char L) {
OP_NOW++;
letter_par[OP_NOW]=(L-'a');
height[OP_NOW]=height[OP_NOW-1]+1;
up[OP_NOW][0]=(OP_NOW-1);
for1(i,20)
up[OP_NOW][i]=up[up[OP_NOW][i-1]][i-1];
}
void UndoCommands(int U) {
OP_NOW++;
height[OP_NOW]=height[OP_NOW-U-1];
letter_par[OP_NOW]=letter_par[OP_NOW-U-1];
for0(i,20)
up[OP_NOW][i]=up[OP_NOW-U-1][i];
}
char GetLetter(int P) {
int N=height[OP_NOW];
if((P+1)==height[OP_NOW])
{
return (letter_par[OP_NOW]+'a');
}
int pos=OP_NOW;
//cout<<pos<<" "<<up[pos][0]<<" "<<up[pos][1]<<" "<<up[pos][2]<<" "<<up[pos][3]<<endl;
fr(i,20,0)
{
//cout<<up[pos][i]<<" "<<height[up[pos][i]]<<endl;
if(height[up[pos][i]]>=(P+1))
{
//cout<<i<<"dddd"<<endl;
pos=up[pos][i];
}
}
return (letter_par[pos]+'a');
}
/*
1000
T a
T b
T d
P 1
*/
컴파일 시 표준 에러 (stderr) 메시지
scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:48:9: warning: unused variable 'N' [-Wunused-variable]
int N=height[OP_NOW];
^
# | 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... |