結果

問題 No.429 CupShuffle
ユーザー Mcpu3Mcpu3
提出日時 2018-09-19 17:18:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 940 ms / 2,000 ms
コード長 1,078 bytes
コンパイル時間 4,286 ms
コンパイル使用メモリ 75,356 KB
実行使用メモリ 69,060 KB
最終ジャッジ日時 2023-09-25 10:12:47
合計ジャッジ時間 9,319 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 213 ms
59,432 KB
testcase_01 AC 135 ms
55,576 KB
testcase_02 AC 144 ms
55,900 KB
testcase_03 AC 139 ms
55,744 KB
testcase_04 AC 201 ms
59,308 KB
testcase_05 AC 137 ms
55,880 KB
testcase_06 AC 207 ms
58,980 KB
testcase_07 AC 219 ms
59,208 KB
testcase_08 AC 146 ms
56,000 KB
testcase_09 AC 208 ms
59,092 KB
testcase_10 AC 424 ms
60,132 KB
testcase_11 AC 890 ms
68,916 KB
testcase_12 AC 899 ms
66,648 KB
testcase_13 AC 940 ms
69,060 KB
testcase_14 AC 855 ms
66,924 KB
testcase_15 AC 135 ms
56,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
    public static void s(int x,int y,int a[]){
        int t=a[x-1];
        a[x-1]=a[y-1];
        a[y-1]=t;
    }

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(),k=sc.nextInt(),x=sc.nextInt(),a[]=new int[k-1],b[]=new int[k-1],c[]=new int[n],f=0,t[]=new int[n];
        String s=new String();
        for(int i=0;i<n;++i)t[i]=i+1;
        for(int i=1;i<x;++i){
            a[0]=sc.nextInt();
            b[0]=sc.nextInt();
            s(a[0],b[0],t);
        }
        for(int i=0;i<2;++i)s=sc.next();
        for(int i=0;i<k-x;++i){
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
        }
        for(int i=0;i<n;++i)c[i]=sc.nextInt();
        sc.close();
        for(int i=k-x-1;i>-1;--i)s(a[i],b[i],c);
        for(int i=0;i<n;++i){
            if(t[i]!=c[i])System.out.print(i+1+" ");
            else if(t[i]!=c[i]&&f>0){
                System.out.print(i+1);
                break;
            }
        }
    }
}
0