結果
問題 | No.429 CupShuffle |
ユーザー | Daigo HIROOKA |
提出日時 | 2018-06-11 00:07:51 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 944 ms / 2,000 ms |
コード長 | 1,131 bytes |
コンパイル時間 | 3,652 ms |
コンパイル使用メモリ | 79,728 KB |
実行使用メモリ | 73,080 KB |
最終ジャッジ日時 | 2023-09-13 02:48:57 |
合計ジャッジ時間 | 10,885 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 218 ms
59,532 KB |
testcase_01 | AC | 152 ms
56,856 KB |
testcase_02 | AC | 162 ms
57,068 KB |
testcase_03 | AC | 156 ms
56,888 KB |
testcase_04 | AC | 218 ms
59,404 KB |
testcase_05 | AC | 153 ms
57,092 KB |
testcase_06 | AC | 222 ms
61,980 KB |
testcase_07 | AC | 228 ms
60,184 KB |
testcase_08 | AC | 162 ms
56,964 KB |
testcase_09 | AC | 222 ms
60,204 KB |
testcase_10 | AC | 436 ms
60,420 KB |
testcase_11 | AC | 901 ms
73,080 KB |
testcase_12 | AC | 898 ms
69,016 KB |
testcase_13 | AC | 944 ms
69,736 KB |
testcase_14 | AC | 876 ms
71,056 KB |
testcase_15 | AC | 154 ms
56,920 KB |
ソースコード
import java.util.*; public class No429{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int X = sc.nextInt(); int[] start = new int[N]; for(int i = 0; i < N; i++){ start[i] = i+1; } int[][] AB = new int[K][2]; for(int i = 0; i < K; i++){ if(i == X-1){ String a = sc.next(); String b = sc.next(); AB[i][0] = 0; AB[i][1] = 0; continue; } AB[i][0] = sc.nextInt(); AB[i][1] = sc.nextInt(); } int[] C = new int[N]; for(int i = 0; i < N; i++){ C[i] = sc.nextInt(); } for(int i = 0; i < X-1; i++){ start = perm(start, AB[i][0]-1, AB[i][1]-1); } for(int i = K-1; i > X-1; i--){ C = perm(C, AB[i][0]-1, AB[i][1]-1); } List<Integer> answer = new ArrayList<Integer>(); for(int i = 0; i < N; i++){ if(start[i] != C[i]) answer.add(i+1); } System.out.println(answer.get(0)+" "+answer.get(1)); } private static int[] perm(int[] list, int idx1, int idx2){ int num1 = list[idx1]; int num2 = list[idx2]; list[idx1] = num2; list[idx2] = num1; return list; } }