結果
問題 |
No.3183 Swap or Rotate
|
ユーザー |
|
提出日時 | 2025-07-15 16:41:28 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 753 bytes |
コンパイル時間 | 840 ms |
コンパイル使用メモリ | 88,260 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-15 16:41:31 |
合計ジャッジ時間 | 2,622 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream> #include <cstdint> #include <vector> static inline std::string solve(const uint_fast16_t N, std::vector<uint_fast16_t>& P) noexcept { std::string ans; ans.reserve(20'000); for (uint_fast16_t length = N; length != 1; --length) { uint_fast16_t cursor; for (cursor = 1; cursor != length; ans.push_back('R'), ++cursor) if (P[cursor - 1] > P[cursor]) std::swap(P[cursor - 1], P[cursor]), ans.push_back('S'); for (; cursor <= N; ++cursor) ans.push_back('R'); } return ans; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast16_t N, i; std::cin >> N; std::vector<uint_fast16_t> P(N); for (i = 0; i != N; ++i) std::cin >> P[i]; std::cout << solve(N, P) << '\n'; return 0; }