Submission #00123


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <bits/stdc++.h>
using namespace std;
int main() {
while (1) {
int n;
cin >> n;
if (n == 0) return(0);
string s;
char c;
string ans = "";
int pos = 0;
for (int i = 0; i < n; i++) {
cin >> s >> c;
if (s == "INSERT") {
ans = ans.substr(0, pos) + c + ans.substr(pos);
pos++;
} else if (s == "LEFT") {
if (pos - 1 >= 0) pos--;
} else {
if (pos + 1 <= ans.size()) pos++;
}
}
cout << ans << "\n";
}
return(0);
}

ステータス

項目 データ
問題 0005 - シンプルなエディタ
ユーザー名 woody_1227
投稿日時 2025-03-28 12:59:43
言語 C++17
状態 Accepted
得点 20
ソースコード長 548 Byte
最大実行時間 34 ms
最大メモリ使用量 548 KB

セット

セット 得点 Cases
1 ALL 20 / 20 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
B1 AC 31 ms 476 KB
1
B2 AC 23 ms 448 KB
1
B3 AC 34 ms 548 KB
1
B4 AC 30 ms 516 KB
1