結果
問題 |
No.3183 Swap or Rotate
|
ユーザー |
|
提出日時 | 2025-06-20 21:27:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 446 bytes |
コンパイル時間 | 1,800 ms |
コンパイル使用メモリ | 195,756 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-20 21:27:18 |
合計ジャッジ時間 | 2,845 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int p[n]; for(int i=0;i<n;i++) cin>>p[i]; string ans=""; auto Swap=[&](){ swap(p[0],p[1]); ans+="S"; }; auto Rotate=[&](){ int x=p[0]; for(int i=0;i<n-1;i++) p[i]=p[i+1]; p[n-1]=x; ans+="R"; }; for(int x=n-2;x>=0;x--){ while(p[0]!=x) Rotate(); while(p[1]!=x+1){ Swap(); Rotate(); } } cout<<ans<<endl; }