結果
| 問題 |
No.397 NO MORE KADOMATSU
|
| コンテスト | |
| ユーザー |
くれちー
|
| 提出日時 | 2016-12-28 19:28:37 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 760 bytes |
| コンパイル時間 | 281 ms |
| コンパイル使用メモリ | 21,504 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 107.94 |
| 最終ジャッジ日時 | 2024-07-17 00:43:25 |
| 合計ジャッジ時間 | 1,724 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:38:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
38 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
main.c:40:33: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
40 | for (i = 0; i < n; i++) scanf("%d", &a[i]);
| ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int ans[100][2];
int cnt = 0;
void swap(int *a, int *b) {
int tmp = *a;
*a = *b;
*b = tmp;
}
void sort(int *d, int s, int idx) {
int i, l = 1;
if (s < 2) return;
for (i = 1; i < s; i++) {
if (d[0] < d[i]) {
if (l != i) {
swap(&d[l], &d[i]);
ans[cnt][0] = l + idx;
ans[cnt][1] = i + idx;
cnt++;
}
l++;
}
}
if (l - 1 != 0) {
swap(&d[0], &d[l - 1]);
ans[cnt][0] = idx;
ans[cnt][1] = l - 1 + idx;
cnt++;
}
sort(d, l, idx);
sort(d + l, s - l, idx + l);
}
int main() {
int n;
scanf("%d", &n);
int a[100], i;
for (i = 0; i < n; i++) scanf("%d", &a[i]);
sort(a, n, 0);
printf("%d\n", cnt);
for (i = 0; i < cnt; i++)
printf("%d %d\n", ans[i][0], ans[i][1]);
fflush(stdout);
return 0;
}
くれちー