結果

問題 No.397 NO MORE KADOMATSU
ユーザー beetbeet
提出日時 2018-08-01 15:37:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 1,300 ms
コンパイル使用メモリ 169,916 KB
実行使用メモリ 24,432 KB
平均クエリ数 427.39
最終ジャッジ日時 2023-09-24 01:52:14
合計ジャッジ時間 3,187 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,556 KB
testcase_01 AC 20 ms
23,796 KB
testcase_02 AC 22 ms
23,652 KB
testcase_03 AC 24 ms
23,652 KB
testcase_04 AC 20 ms
24,420 KB
testcase_05 AC 22 ms
23,388 KB
testcase_06 AC 20 ms
24,072 KB
testcase_07 AC 22 ms
23,448 KB
testcase_08 AC 20 ms
24,432 KB
testcase_09 AC 19 ms
23,376 KB
testcase_10 AC 21 ms
23,652 KB
testcase_11 AC 20 ms
23,808 KB
testcase_12 AC 20 ms
23,664 KB
testcase_13 AC 28 ms
23,364 KB
testcase_14 AC 28 ms
23,652 KB
testcase_15 AC 26 ms
23,664 KB
testcase_16 AC 21 ms
23,568 KB
testcase_17 AC 20 ms
23,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  using P = pair<Int, Int>;
  vector<P> ans;
  for(Int i=0;i<n;i++){
    for(Int j=0;j<n;j++){
      if(a[i]>a[j]){
	swap(a[i],a[j]);
	ans.emplace_back(i,j);
      }
    }
  }
  cout<<ans.size()<<endl;
  for(auto p:ans) cout<<p.first<<" "<<p.second<<endl;
  Int d;
  cin>>d;
  return 0;
}
0