結果

問題 No.3183 Swap or Rotate
ユーザー neet
提出日時 2025-06-21 00:20:50
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 900 bytes
コンパイル時間 3,282 ms
コンパイル使用メモリ 278,944 KB
実行使用メモリ 16,064 KB
最終ジャッジ日時 2025-06-21 00:20:56
合計ジャッジ時間 6,232 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
// #include<atcoder/all>
// using mint = atcoder::modint998244353;
using ld = long double;
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename T>bool chmin(T&a,T b){return b<a?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return b>a?(a=b,1):0;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N;
    cin>>N;
    vector<int> P(N);
    rep(i,N)cin>>P[i];

    while(1){
        int c=0;
        rep(i,N-1) if(P[i]>P[i+1]) c++;
        if(c==0) break;
        if(c==1){
            if(P[0]>P[1]){
                swap(P[0],P[1]);
                cout<<"S";
            }
            continue;
        }
        if(P[0]<P[1]) swap(P[0],P[1]);
        P.push_back(P[0]);
        P.erase(P.begin());
        cout<<"R";
    }
    cout<<"\n";
}
0