結果

問題 No.397 NO MORE KADOMATSU
ユーザー mamekinmamekin
提出日時 2016-10-07 14:58:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 968 bytes
コンパイル時間 953 ms
コンパイル使用メモリ 106,580 KB
実行使用メモリ 24,420 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:34:40
合計ジャッジ時間 2,659 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,180 KB
testcase_01 AC 24 ms
24,012 KB
testcase_02 AC 23 ms
23,616 KB
testcase_03 AC 25 ms
23,364 KB
testcase_04 AC 23 ms
23,976 KB
testcase_05 AC 24 ms
23,616 KB
testcase_06 AC 27 ms
23,988 KB
testcase_07 AC 28 ms
23,964 KB
testcase_08 AC 24 ms
24,420 KB
testcase_09 AC 23 ms
23,508 KB
testcase_10 AC 53 ms
23,604 KB
testcase_11 AC 23 ms
23,376 KB
testcase_12 AC 32 ms
23,604 KB
testcase_13 AC 36 ms
23,364 KB
testcase_14 AC 33 ms
23,352 KB
testcase_15 AC 36 ms
23,784 KB
testcase_16 AC 23 ms
23,520 KB
testcase_17 AC 23 ms
23,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int 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-1; ++i){
        for(int j=0; j<n-1; ++j){
            if(a[j] > a[j+1]){
                ans.push_back(make_pair(j, j + 1));
                swap(a[j], a[j+1]);
            }
        }
    }

    cout << ans.size() << endl;
    for(const auto& p : ans)
        cout << p.first << ' ' << p.second << endl;

    int dummy;
    cin >> dummy;
    return 0;
}
0