結果
| 問題 | No.3489 あみだくじ作り |
| コンテスト | |
| ユーザー |
よには
|
| 提出日時 | 2026-04-03 21:49:57 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,061 bytes |
| 記録 | |
| コンパイル時間 | 8,937 ms |
| コンパイル使用メモリ | 411,976 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-03 21:50:21 |
| 合計ジャッジ時間 | 7,394 ms |
|
ジャッジサーバーID (参考情報) |
judge5_1 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#if __has_include(<yoniha/all.h>)
#include <yoniha/all.h>
using namespace atcoder;
#else
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#endif
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)((n) - 1); i >= 0; i--)
template <typename T> bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template <typename T> bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
// using mint = modint;
signed main(){
int n; cin >> n;
vector<int> p(n); for(auto&& pi : p) cin >> pi, pi--;
println("Yes");
vector<int> ans;
rep(i, n){
// i番目にiが来るようにする
rep(j, n) if(p.at(j) == i){
// j-1からiまで横棒を書く
for(int k = j - 1; k >= i; k--){
swap(p.at(k), p.at(k + 1));
ans.emplace_back(k);
}
}
}
println("{}", ans.size());
for(auto i : ans) println("{}", i + 1);
}
よには