結果

問題 No.397 NO MORE KADOMATSU
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-07-16 01:11:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,011 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 65,660 KB
実行使用メモリ 24,372 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:20:00
合計ジャッジ時間 2,265 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,688 KB
testcase_01 AC 24 ms
24,300 KB
testcase_02 AC 25 ms
23,556 KB
testcase_03 AC 25 ms
23,616 KB
testcase_04 AC 25 ms
23,424 KB
testcase_05 AC 26 ms
23,520 KB
testcase_06 AC 27 ms
23,424 KB
testcase_07 AC 27 ms
24,084 KB
testcase_08 AC 25 ms
23,892 KB
testcase_09 AC 24 ms
23,664 KB
testcase_10 AC 43 ms
23,592 KB
testcase_11 AC 25 ms
24,024 KB
testcase_12 AC 30 ms
23,412 KB
testcase_13 AC 34 ms
24,372 KB
testcase_14 AC 33 ms
23,436 KB
testcase_15 AC 33 ms
23,820 KB
testcase_16 AC 24 ms
23,688 KB
testcase_17 AC 24 ms
24,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)

int a[101];
int n;
//バブルソート
void sort(void){
    vpint ans;
    bool zerof = 1;
    bool flag = 1;
    for (int i = 0; flag; ++i){
        flag = 0;
        for (int j = n - 1; j >= i ; --j){
            if(a[j] < a[j - 1]){
                swap(a[j], a[j - 1]);
                ans.push_back(mp(j - 1, j));
                flag = 1;
                zerof = 0;
            }
        }
    }
    //変更した位置を記録しておく
    int size = ans.size(); printf("%d\n", size);
    rep(i, size) printf("%d %d\n", ans[i].fi, ans[i].se);
    return;
}
int main(void){
    cin >> n;
    rep(i, n) cin >> a[i];
    sort();
    int d; cin >> d;
    return 0;
}
0