結果

問題 No.397 NO MORE KADOMATSU
ユーザー alpha_virginisalpha_virginis
提出日時 2016-11-16 21:11:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 1,442 ms
コンパイル使用メモリ 169,940 KB
実行使用メモリ 25,476 KB
平均クエリ数 2019.33
最終ジャッジ日時 2024-07-17 00:37:15
合計ジャッジ時間 3,019 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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