Submission #00070
ソースコード
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 28 29 30 31 32 33 34 35 36 | #include<bits/stdc++.h> using namespace std; #define int long signed main(){ while (1){ int n;cin>>n; if (n==0) return 0; int p=0; string ans; for ( int i=0;i<n;i++){ string s,t1,t2; char a; cin>>s>>a; if (s== "INSERT" ){ if (ans.empty())ans=a; else { for ( int j=0;j<ans.size();j++){ if (j<p){ t1+=ans[j]; } else if (j>=p){ t2+=ans[j]; } } } ans=t1+a+t2; p++; } else if (s== "LEFT" ){ p=max(0L,p-1); } else if (s== "RIGHT" ){ p=min(( long )ans.size(),p+1); } //cout<<ans<<" "<<p<<"\n"; } cout<<ans<< "\n" ; } } |
ステータス
項目 | データ |
---|---|
問題 | 0005 - シンプルなエディタ |
ユーザー名 | ei2331 |
投稿日時 | 2025-03-28 11:36:29 |
言語 | C++17 |
状態 | Accepted |
得点 | 20 |
ソースコード長 | 935 Byte |
最大実行時間 | 35 ms |
最大メモリ使用量 | 672 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 20 / 20 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
B1 | AC | 32 ms | 476 KB |
1
|
B2 | AC | 33 ms | 448 KB |
1
|
B3 | AC | 35 ms | 672 KB |
1
|
B4 | AC | 28 ms | 640 KB |
1
|