結果

問題 No.397 NO MORE KADOMATSU
ユーザー ngtkanangtkana
提出日時 2020-03-19 23:34:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 2,008 ms
コンパイル使用メモリ 204,320 KB
実行使用メモリ 24,540 KB
平均クエリ数 640.78
最終ジャッジ日時 2023-09-24 03:11:40
合計ジャッジ時間 5,703 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,436 KB
testcase_01 AC 25 ms
23,892 KB
testcase_02 AC 24 ms
23,436 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 24 ms
23,712 KB
testcase_10 WA -
testcase_11 AC 25 ms
23,484 KB
testcase_12 AC 32 ms
23,916 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 24 ms
23,280 KB
testcase_17 AC 24 ms
23,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    std::vector<std::pair<lint,lint>>ans;
    for(lint i=0;i<n;i++){
        for(lint j=i;j<n-1;j++){
            if(a.at(j)>a.at(j+1)){
                ans.emplace_back(j,j+1);
                std::swap(a.at(j),a.at(j+1));
            }
        }
    }
    std::cout<<ans.size()<<'\n';
    for(auto&&p:ans){
        std::cout<<p.first<<" "<<p.second<<std::endl;
    }
    std::cout<<std::flush;
}
0