이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h> //:3
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sz(x) (int)((x).size())
//#define int long long
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const ll inf = 2e9;
const ll mod = 1e9 + 7;
const int N = 1e6 + 11;
const ll INF64 = 3e18 + 1;
const double eps = 1e-14;
const double PI = acos(-1);
//ifstream in(".in");
//ofstream out(".out");
int v[N], tip[N], p[N], lvl[N], dp[N][25], k;
void Init(){};
void TypeLetter(char L){
int nod = v[k];
v[++k] = k;
tip[k] = L - 'a';
if(tip[nod] == -1){
p[k] = p[nod];
}else{
p[k] = nod;
}
lvl[k] = lvl[p[k]] + 1;
dp[k][0] = p[k];
for(int i = 1; i <= 20; i++){
dp[k][i] = dp[dp[k][i - 1]][i - 1];
}
}
void UndoCommands(int U){
int nod = v[k - U];
v[++k] = k;
tip[k] = -1;
if(tip[nod] == -1){
p[k] = p[nod];
}else{
p[k] = nod;
}
}
char GetLetter(int P){
int nod = v[k];
if(tip[nod] == -1)nod = p[nod];
int len = lvl[nod] - P - 1;
for(int i = 20; i >= 0; i--){
if((1 << i) <= len){
nod = dp[nod][i];
len -= (1 << i);
}
}
return (char)(tip[nod] + 'a');
}
컴파일 시 표준 에러 (stderr) 메시지
scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:33:7: warning: operation on 'k' may be undefined [-Wsequence-point]
33 | v[++k] = k;
| ^~~
scrivener.cpp:33:7: warning: operation on 'k' may be undefined [-Wsequence-point]
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:54:7: warning: operation on 'k' may be undefined [-Wsequence-point]
54 | v[++k] = k;
| ^~~
scrivener.cpp:54:7: warning: operation on 'k' may be undefined [-Wsequence-point]
# | 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... |