結果

問題 No.3183 Swap or Rotate
ユーザー D M
提出日時 2025-09-18 09:54:27
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 729 bytes
コンパイル時間 6,058 ms
コンパイル使用メモリ 335,004 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-18 09:54:38
合計ジャッジ時間 9,301 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
const ll MOD = 998244353;
#include<atcoder/all>
using namespace atcoder;
using mint = modint998244353;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;cin>>n;
  vector<ll> P(n);
  rep(i,n)cin>>P[i];
  ll now=0,cnt=0;
  while(cnt<=n){
    if(P[now]>P[(now+1)%n] && !(P[now]==n-1 && P[(now+1)%n]==0)){
        cout<<'S';
        swap(P[now],P[(now+1)%n]);
        cnt=0;
    }else{
        cout<<'R';
        now=(now+n-1)%n;
        cnt++;
    }
  }
  ll c;
  rep(i,n){
    if(P[i]==0)c=i;
    break;
  }
  rep(i,(c-now+n)%n){
    cout<<'R';
  }
}
0