結果

問題 No.397 NO MORE KADOMATSU
ユーザー T1610
提出日時 2019-04-01 01:58:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 988 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 169,948 KB
実行使用メモリ 25,220 KB
平均クエリ数 936.56
最終ジャッジ日時 2024-07-17 02:12:47
合計ジャッジ時間 3,705 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    vector<int> a;
    rep(i, N) rep(j, N-1) if(v[j] > v[j+1]) {
        // cout << j << " " << j+1 << '\n';
        a.pb(j);
        swap(v[j], v[j+1]);
    }
    cout << a.size() << '\n';
    rep(i, a.size()) cout << a[i] << " " << a[i]+1 << '\n';
    cout << flush;
    int d;
    cin >> d;
    return 0;
}
0