結果

問題 No.429 CupShuffle
ユーザー Mcpu3Mcpu3
提出日時 2018-09-19 17:06:40
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 29,168 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 10:12:01
合計ジャッジ時間 1,562 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 31 ms
4,376 KB
testcase_12 AC 29 ms
4,376 KB
testcase_13 AC 31 ms
4,380 KB
testcase_14 AC 31 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

void s(int x,int y,int *a)
{
    int t=a[x-1];
    a[x-1]=a[y-1];
    a[y-1]=t;
}

int main(void)
{
    int n,k,x,a[99999],b[99999],c[100000],f=0,t[100000],i;
    scanf("%d%d%d",&n,&k,&x);
    for(i=0;i<n;++i)t[i]=i+1;
    for(i=1;i<x;++i){
        scanf("%d%d",&a[0],&b[0]);
        s(a[0],b[0],t);
    }
    scanf("%*s%*s");
    for(i=0;i<k-x;++i)scanf("%d%d",&a[i],&b[i]);
    for(i=0;i<n;++i)scanf("%d",&c[i]);
    for(i=k-x-1;i>-1;--i)s(a[i],b[i],c);
    for(i=0;i<n;++i){
        if(t[i]!=c[i])printf("%d ",i+1);
        else if(t[i]!=c[i]&&f){
            printf("%d",i+1);
            break;
        }
    }
    return 0;
}
0