結果
問題 |
No.3183 Swap or Rotate
|
ユーザー |
![]() |
提出日時 | 2025-06-20 21:23:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 650 bytes |
コンパイル時間 | 3,808 ms |
コンパイル使用メモリ | 253,388 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-20 21:23:16 |
合計ジャッジ時間 | 6,262 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:30: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized] 25 | if((x+1)%n==y)break; | ~~^~~ main.cpp:20:29: note: ‘x’ was declared here 20 | int x,y; | ^ main.cpp:25:25: warning: ‘y’ may be used uninitialized [-Wmaybe-uninitialized] 25 | if((x+1)%n==y)break; | ^~ main.cpp:20:31: note: ‘y’ was declared here 20 | int x,y; | ^
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000005 #define Inf64 4000000000000000001LL int main(){ int n; cin>>n; vector<int> p(n); rep(i,n)cin>>p[i]; string ans = ""; for(int i=n-2;i>=0;i--){ while(true){ int x,y; rep(j,n){ if(p[j]==i)x = j; if(p[j]==i+1)y = j; } if((x+1)%n==y)break; if(x==0){ ans += 'S'; swap(p[0],p[1]); } else{ ans += 'R'; p.push_back(p[0]); p.erase(p.begin()); } } } cout<<ans<<endl; return 0; }