結果

問題 No.397 NO MORE KADOMATSU
ユーザー yosupot
提出日時 2016-07-15 22:39:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 967 bytes
コンパイル時間 910 ms
コンパイル使用メモリ 105,344 KB
実行使用メモリ 25,220 KB
平均クエリ数 936.56
最終ジャッジ日時 2024-07-17 00:03:37
合計ジャッジ時間 2,621 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    using P = pair<int, int>;
    vector<P> res;
    for (int i = 0; i < n; i++) {
        for (int j = n-1; j-1 >= i; j--) {
            if (a[j-1] > a[j]) {
                res.push_back(P(j-1, j));
                swap(a[j-1], a[j]);
            }
        }
    }
    cout << res.size() << endl;
    for (P p: res) {
        cout << p.first << " " << p.second << endl;
    }
    int d;
    cin >> d;
    return 0;
}
0