結果
| 問題 | No.397 NO MORE KADOMATSU |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-22 21:10:22 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 746 bytes |
| 記録 | |
| コンパイル時間 | 446 ms |
| コンパイル使用メモリ | 87,016 KB |
| 実行使用メモリ | 28,720 KB |
| 平均クエリ数 | 936.56 |
| 最終ジャッジ日時 | 2026-03-22 21:10:28 |
| 合計ジャッジ時間 | 3,221 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
typedef pair<int, int> PII;
const int N = 110;
int n, a[N];
vector<PII> ans;
int main() {
// freopen("no.in", "r", stdin);
// freopen("no.out", "w", stdout);
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (a[j - 1] > a[j]) {
swap(a[j - 1], a[j]);
ans.push_back({ j - 1, j });
}
}
}
printf("%d\n", ans.size());
for (int i = 0; i < ans.size(); ++i) {
printf("%d %d\n", ans[i].first - 1, ans[i].second - 1);
}
return 0;
}