結果
| 問題 |
No.3183 Swap or Rotate
|
| コンテスト | |
| ユーザー |
蜜蜂
|
| 提出日時 | 2025-06-02 22:44:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 565 bytes |
| コンパイル時間 | 849 ms |
| コンパイル使用メモリ | 88,624 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-15 12:30:51 |
| 合計ジャッジ時間 | 1,916 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> p(n);
for(int i = 0; i < n; i++) cin >> p[i];
string ans = "";
auto s = [&](){
ans += 'S';
swap(p[0], p[1]);
};
auto r = [&](){
ans += 'R';
for(int i = 0; i < n - 1; i++) swap(p[i], p[i + 1]);
};
while(p[n - 1] != n - 1) r();
for(int i = n - 2; i >= 0; i--){
if(p[i] == i) continue;
while(p[0] != i) r();
while(p[1] != i + 1){
s();
r();
}
while(p[i] != i) r();
}
cout << ans << endl;
}
蜜蜂