結果
| 問題 |
No.3183 Swap or Rotate
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-20 22:43:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,058 bytes |
| コンパイル時間 | 3,001 ms |
| コンパイル使用メモリ | 282,032 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 22:43:59 |
| 合計ジャッジ時間 | 6,487 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n; cin >> n;
vector<int> p(n);
for (int &x : p) cin >> x;
auto finished = [&] () -> bool {
for (int i = 0; i < n; i++) {
if (p[i] != i) return false;
}
return true;
};
vector<bool> ok(n, false);
ok[0] = true;
auto update = [&] () -> void {
for (int i = 0; i < n; i++) {
if (p[i] == 0) {
for (int j = 1; j < n; j++) {
int k = (i + j) % n;
if (p[k] == j) ok[j] = true;
else break;
}
break;
}
}
};
update();
string ans;
while (!finished()) {
if (!ok[p[0]] && !ok[p[1]]) {
ans += 'S';
swap(p[0], p[1]);
update();
}
ans += 'R';
rotate(p.begin(), p.begin() + 1, p.end());
}
cout << ans << "\n";
return 0;
}