結果

問題 No.397 NO MORE KADOMATSU
ユーザー alpha_virginisalpha_virginis
提出日時 2016-11-16 21:11:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 168,980 KB
実行使用メモリ 24,336 KB
平均クエリ数 2019.33
最終ジャッジ日時 2023-09-24 00:42:22
合計ジャッジ時間 3,417 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,808 KB
testcase_01 AC 27 ms
23,988 KB
testcase_02 AC 26 ms
24,336 KB
testcase_03 AC 32 ms
23,412 KB
testcase_04 AC 28 ms
23,496 KB
testcase_05 AC 32 ms
23,796 KB
testcase_06 AC 31 ms
23,604 KB
testcase_07 AC 32 ms
23,628 KB
testcase_08 AC 27 ms
23,628 KB
testcase_09 AC 43 ms
23,808 KB
testcase_10 AC 44 ms
23,388 KB
testcase_11 AC 44 ms
23,604 KB
testcase_12 AC 43 ms
23,796 KB
testcase_13 AC 38 ms
23,628 KB
testcase_14 AC 38 ms
23,628 KB
testcase_15 AC 38 ms
23,628 KB
testcase_16 AC 27 ms
24,228 KB
testcase_17 AC 26 ms
24,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int n;
int xs[128];
std::vector<std::pair<int, int>> res;

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%d", &xs[i]);
  }

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < n - 1 - i; ++j) {
      if( xs[j] >= xs[j+1] ) {
        std::swap(xs[j], xs[j+1]);
        res.push_back(std::make_pair(j, j + 1));
      }
    }
  }
  printf("%d\n", (int)res.size());
  for(auto xy : res) {
    printf("%d %d\n", xy.first, xy.second);
  }
  fflush(stdout);

  int dummy;
  scanf("%d", &dummy);
  
  return 0;
}
0