結果

問題 No.429 CupShuffle
コンテスト
ユーザー Mcpu3
提出日時 2018-09-19 17:18:12
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 618 ms / 2,000 ms
+ 26µs
コード長 1,078 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,415 ms
コンパイル使用メモリ 85,724 KB
実行使用メモリ 58,772 KB
最終ジャッジ日時 2026-08-16 18:08:32
合計ジャッジ時間 6,442 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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