結果

問題 No.397 NO MORE KADOMATSU
ユーザー yuma25689yuma25689
提出日時 2016-07-16 00:11:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 803 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 66,552 KB
実行使用メモリ 24,408 KB
平均クエリ数 38.72
最終ジャッジ日時 2023-09-23 11:09:24
合計ジャッジ時間 4,036 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef pair<int,int> PII;

void solve()
{
    int N;
    cin >> N;
    
    vector<int> input(N+1);
    
    for( int i=0; i<N; i++ )
    {
        cin >> input[i];
    }
    
    vector<PII> ans;
    
    for( int i=N-1; 0<i; i-- )
    {
        if( input[i] < input[i-1] )
        {
            swap( input[i-1], input[i] );
            ans.push_back( PII( i-1, i ) );
        }
    }
    
    cout << ans.size() << endl;
    for( auto itr = ans.begin(); itr != ans.end(); ++itr )
    {
        cout << itr->first+1 << " " << itr->second+1 << endl;
    }
    cout << flush;
    int dummy;
    cin >> dummy;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}
0