結果

問題 No.3183 Swap or Rotate
ユーザー zawakasu
提出日時 2025-06-20 21:32:14
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,547 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 125,388 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-06-20 21:32:27
合計ジャッジ時間 4,538 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 11 RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <tuple>
#include <ranges>
namespace ranges = std::ranges;
namespace views = std::views;
// #include "Src/Number/IntegerDivision.hpp"
// #include "Src/Utility/BinarySearch.hpp"
// #include "Src/Sequence/CompressedSequence.hpp"
// #include "Src/Sequence/RunLengthEncoding.hpp"
// #include "Src/Algebra/Group/AdditiveGroup.hpp"
// #include "Src/DataStructure/FenwickTree/FenwickTree.hpp"
// #include "Src/DataStructure/SegmentTree/SegmentTree.hpp"
// #include "Src/DataStructure/DisjointSetUnion/DisjointSetUnion.hpp"
// using namespace zawa;
// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
int N, P[100];
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cin >> N;
    for (int i = 0 ; i < N ; i++) std::cin >> P[i];
    std::string ans;
    while (true) {
        int f = -1;
        for (int i = 0 ; f == -1 and i < N ; i++) {
            if (P[i] > P[i + 1] and P[(i + 1) % N] != 0) f = i;
        }
        if (f == -1) break;
        ans += std::string(f, 'R');
        std::vector<int> p(N);
        for (int i = 0 ; i < N ; i++) p[i] = P[(i + f) % N];
        for (int i = 0 ; i < N ; i++) P[i] = p[i];
        assert(P[0] > P[1] and P[1] != 0);
        ans += 'S';
        std::swap(P[0], P[1]);
    }
    int f = ranges::find(P, P + N, 0) - P;
    ans += std::string(f, 'R');
    std::cout << ans << '\n';
}
0