結果
問題 | No.429 CupShuffle |
ユーザー | YamaKasa |
提出日時 | 2018-09-20 16:57:08 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 959 ms / 2,000 ms |
コード長 | 1,028 bytes |
コンパイル時間 | 2,213 ms |
コンパイル使用メモリ | 76,664 KB |
実行使用メモリ | 67,648 KB |
最終ジャッジ日時 | 2023-09-25 10:34:19 |
合計ジャッジ時間 | 9,592 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 212 ms
59,744 KB |
testcase_01 | AC | 151 ms
56,896 KB |
testcase_02 | AC | 157 ms
56,840 KB |
testcase_03 | AC | 157 ms
57,164 KB |
testcase_04 | AC | 219 ms
61,000 KB |
testcase_05 | AC | 152 ms
57,080 KB |
testcase_06 | AC | 220 ms
59,840 KB |
testcase_07 | AC | 225 ms
60,168 KB |
testcase_08 | AC | 162 ms
56,988 KB |
testcase_09 | AC | 226 ms
60,104 KB |
testcase_10 | AC | 426 ms
60,440 KB |
testcase_11 | AC | 913 ms
67,240 KB |
testcase_12 | AC | 918 ms
67,648 KB |
testcase_13 | AC | 959 ms
67,244 KB |
testcase_14 | AC | 919 ms
66,896 KB |
testcase_15 | AC | 151 ms
56,884 KB |
ソースコード
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int K = scan.nextInt(); int X = scan.nextInt() - 1; int[]A = new int[K]; int[]B = new int[K]; for(int i = 0; i < K; i++) { if(i == X) { scan.next(); scan.next(); A[i] = 0; B[i] = 0; }else { A[i] = scan.nextInt() - 1; B[i] = scan.nextInt() - 1; } } int[]C = new int[N]; int[]C1 = new int[N]; for(int i = 0; i < N; i++) { C[i] = scan.nextInt(); C1[i] = i + 1; } scan.close(); for(int i = 0; i < X; i++) { swap(C1, A[i], B[i]); } for(int i = K - 1; i > X; i--) { swap(C, A[i], B[i]); } ArrayList<Integer> list = new ArrayList<Integer>(); for(int i = 0; i < N; i++) { if(C[i] != C1[i]) { list.add(i + 1); } } System.out.println(list.get(0) + " " + list.get(1)); } static void swap(int[]A, int i, int j) { int t = A[j]; A[j] = A[i]; A[i] = t; } }