結果
問題 |
No.3183 Swap or Rotate
|
ユーザー |
![]() |
提出日時 | 2025-07-02 16:36:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 682 bytes |
コンパイル時間 | 2,085 ms |
コンパイル使用メモリ | 196,372 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-07-02 16:36:18 |
合計ジャッジ時間 | 4,567 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector<int> p(n); for (int i = 0; i < n; i++) { cin >> p[i]; } string ans = ""; int pos = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1 - i; j++) { if (p[j] > p[j + 1]) { while (pos != j) { ans.push_back('R'); pos = (pos + 1) % n; } swap(p[j], p[j + 1]); ans.push_back('S'); } } } cout << ans << endl; }