結果
問題 | No.429 CupShuffle |
ユーザー | kohaku_kohaku |
提出日時 | 2016-11-16 14:19:53 |
言語 | Java19 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,220 bytes |
コンパイル時間 | 2,691 ms |
コンパイル使用メモリ | 76,456 KB |
実行使用メモリ | 64,616 KB |
最終ジャッジ日時 | 2023-08-17 07:24:26 |
合計ジャッジ時間 | 6,304 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int [] Cupf = new int [N]; for(int i=0; i<N; i++){ Cupf[i]=i+1; } int K = sc.nextInt(); int [] A = new int [K]; int [] B = new int [K]; int X = sc.nextInt(); for(int i=0; i<K; i++){ if(i!=X-1){ A[i]=sc.nextInt(); B[i]=sc.nextInt(); } } for(int i=0; i<X-1; i++){ int t = Cupf[ A[i]-1 ]; Cupf[ A[i]-1 ] = Cupf[ B[i]-1 ]; Cupf[ B[i]-1 ] = t; } int [] Cupt = new int [N]; for(int i=0; i<N; i++){ Cupt[i]=sc.nextInt(); } for(int i=K-1; i>X-1; i--){ int t = Cupt[ A[i]-1 ]; Cupt[ A[i]-1 ] = Cupt[ B[i]-1 ]; Cupt[ B[i]-1 ] = t; } int [] r = new int [2]; int z =0; for(int i=0; i<N; i++){ if(Cupf[i]!=Cupt[i]){ r[z]=i+1; z++; } } System.out.println(r[0]+" "+r[1]); } }