結果

問題 No.397 NO MORE KADOMATSU
ユーザー kpinkcatkpinkcat
提出日時 2023-12-11 02:06:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 1,242 ms
コンパイル使用メモリ 114,608 KB
実行使用メモリ 24,012 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-12-11 02:06:25
合計ジャッジ時間 3,086 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,000 KB
testcase_01 AC 24 ms
24,000 KB
testcase_02 AC 24 ms
24,000 KB
testcase_03 AC 25 ms
24,000 KB
testcase_04 AC 25 ms
24,000 KB
testcase_05 AC 29 ms
24,000 KB
testcase_06 AC 29 ms
24,000 KB
testcase_07 AC 30 ms
24,000 KB
testcase_08 AC 27 ms
24,000 KB
testcase_09 AC 24 ms
24,000 KB
testcase_10 AC 59 ms
24,000 KB
testcase_11 AC 24 ms
24,000 KB
testcase_12 AC 35 ms
24,000 KB
testcase_13 AC 40 ms
24,000 KB
testcase_14 AC 41 ms
24,000 KB
testcase_15 AC 41 ms
24,000 KB
testcase_16 AC 24 ms
24,012 KB
testcase_17 AC 24 ms
24,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
using namespace std;
using ll = long long;

int main()
{
    int n, cnt = 0;
    cin >> n;
    vector<int> v(n);
    vector<vector<int>> ch;
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i < n - 1; i++){
        for (int j = 0; j < n-i-1; j++){
            if (v[j] > v[j+1]){
                swap(v[j], v[j+1]);
                ch.push_back({j, j+1});
                cnt++;
            }
        }   
    }
    cout << cnt << endl;
    for (auto x : ch){
        for (auto y1 : x){
            cout << y1 << " ";
        }
        cout << endl;
    }
    //for (auto x : v){
    //    cout << x << " ";
    //}
    //cout << endl;
    cin >> cnt;
}
0