結果

問題 No.326 あみだますたー
ユーザー なお
提出日時 2015-12-22 02:28:59
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 160,868 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 23:23:41
合計ジャッジ時間 2,760 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
#define in(T,V) T V;cin>>V;

int X[6666],Y[6666];
int A[111];

int main(){
    in(int,N);
    in(int,K);
    REP(i,K){
        cin >> X[i] >> Y[i]; X[i]--, Y[i]--;
    }
    REP(i,N){
        cin >> A[i]; A[i]--;
    }

    int a[111];
    REP(i,N) a[i] = A[i];
    REP(i,K){
        swap(a[X[i]],a[X[i]+1]);
    }

    VI res;
    REP(i,N) REP(j,N-1){
        if(a[j] > a[j+1]){
            swap(a[j], a[j+1]);
            res.push_back(j);
        }
    }
    cout << res.size() << endl;
    for(auto &v : res){
        cout << v+1 << " " << v+2 << endl;
    }
}
0