結果

問題 No.3183 Swap or Rotate
ユーザー ゼリトキ
提出日時 2025-06-20 22:22:26
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 770 bytes
コンパイル時間 3,550 ms
コンパイル使用メモリ 277,148 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-20 22:22:31
合計ジャッジ時間 4,303 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
const long long mod=998244353;
const long long hmod=46216567629137;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    cout.tie(0);
    int N;
    cin>>N;
    int P[109];
    for(int i=1;i<=N;i++) cin>>P[i];
    string ans="";
    while(true){
        bool check=1;
        for(int i=1;i<=N;i++){
            if(P[i]!=i-1) check=0;
        }
        if(check) break; 
        if((P[1]==N-1 && P[2]==0) || P[1]<P[2]){
            int move=P[1];
            for(int i=1;i<=N-1;i++) P[i]=P[i+1];
            P[N]=move;
            ans+="R";
        }
        else{
            swap(P[1],P[2]);
            ans+="S";
        }
    }
    cout<<ans<<endl;
}
0