結果

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

テストケース

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

ソースコード

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::cin>>n;
    std::cout<<std::flush;
}
0