結果

問題 No.397 NO MORE KADOMATSU
コンテスト
ユーザー 0w1
提出日時 2016-11-26 15:15:43
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 565 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,036 ms
コンパイル使用メモリ 185,164 KB
実行使用メモリ 28,720 KB
平均クエリ数 0.39
最終ジャッジ日時 2026-03-30 23:32:27
合計ジャッジ時間 5,032 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 2 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

signed main(){
  int N; cin >> N;
  vector< int > A( N );
  for( int i = 0; i < N; ++i )
    cin >> A[ i ];
  vector< pair< int, int > > ans;
  for( int i = 0; i < N; ++i )
    for( int j = 0; j + 1 < N; ++j )
      if( A[ j ] > A[ j + 1 ] )
        swap( A[ j ], A[ j + 1 ] ),
        ans.emplace_back( j, j + 1 );
  if( ans.empty() )
    cout << -1 << endl;
  else{
    for( int i = 0; i < ans.size(); ++i )
      cout << ans[ i ].first << " " << ans[ i ].second << endl;
  }
  int dummy; cin >> dummy;
  return 0;
}
0