結果
| 問題 |
No.3183 Swap or Rotate
|
| コンテスト | |
| ユーザー |
Ponzu
|
| 提出日時 | 2025-06-21 09:28:16 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 541 bytes |
| コンパイル時間 | 962 ms |
| コンパイル使用メモリ | 85,460 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-21 09:28:19 |
| 合計ジャッジ時間 | 2,299 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
bool check(vector<int>&p,int offset){
int n = p.size();
for(int i=0;i<n-1;++i){
if(p[(i+offset)%n] > p[(i+offset+1)%n]) return false;
}
return true;
}
int main(){
int n;cin>>n;
vector<int>p(n);
for(int i=0;i<n;++i)cin>>p[i];
int offset = 0;
while(1){
if(check(p,offset)){
cout << endl;
return 0;
}
if(p[offset%n] > p[(offset+1)%n] && p[offset%n] != n-1){
swap(p[offset%n] , p[(offset+1)%n]);
cout << 'S';
} else {
offset++;
cout << 'R';
}
}
}
Ponzu