結果

問題 No.326 あみだますたー
ユーザー maimai
提出日時 2016-06-25 16:44:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 162,928 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 04:24:27
合計ジャッジ時間 6,704 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 1 ms
6,944 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,944 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 WA -
testcase_24 WA -
testcase_25 RE -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long int ll;

int vo[100];
int va[100];
int vi[100];
int q[100],qsize;

int main(){
    int i,j,k,l;
    int m,n;
    
    cin>>n>>m;
    
    iota(vo,vo+n,1);
    
    for (i=0;i<m;i++){
        scanf("%d%d",&k,&l);
        swap(vo[k-1],vo[l-1]);
    }
    
    for (i=0;i<n;i++){
        scanf("%d",&k);
        vi[i]=k;
    }
    for (i=0;i<n;i++)
        va[vi[i]-1]=i+1;
    
    //for (int e:vo)cout<<e<<" ";cout<<endl;
    //for (int e:va)cout<<e<<" ";cout<<endl;
    
    for (i=0;i<(n-1);i++){
        for (j=n;i<j;j--){
            if (vo[j]==va[i]){
                swap(vo[j],vo[j-1]);
                q[qsize++]=j;
            }
        }
    }
    
    printf("%d\n",qsize);
    while (0<=--qsize){
        printf("%d %d\n",q[qsize],q[qsize]+1);
    }
    
    return 0;
}
0