結果
問題 | No.326 あみだますたー |
ユーザー | uafr_cs |
提出日時 | 2016-02-02 21:22:00 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,295 bytes |
コンパイル時間 | 2,562 ms |
コンパイル使用メモリ | 80,520 KB |
実行使用メモリ | 63,156 KB |
最終ジャッジ日時 | 2023-10-21 18:44:42 |
合計ジャッジ時間 | 14,262 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
ソースコード
import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); int[] current = new int[N]; for(int i = 0; i < N; i++){ current[i] = i; } final int K = sc.nextInt(); for(int i = 0; i < K; i++){ final int X = sc.nextInt() - 1; final int Y = sc.nextInt() - 1; { final int tmp = current[X]; current[X] = current[Y]; current[Y] = tmp; } } //System.out.println(Arrays.toString(current)); int[] purpose = new int[N]; for(int i = 0; i < N; i++){ purpose[i] = sc.nextInt(); } LinkedList<String> answers = new LinkedList<String>(); for(int i = 0; i < N; i++){ if(current[i] != purpose[i]){ for(int index = 0; index < N; index++){ if(current[index] != purpose[i]){ continue; } { answers.add((i + 1) + " " + (index + 1)); int tmp = current[index]; current[index] = current[i]; current[i] = tmp; break; } } } } System.out.println(answers.size()); for(String str : answers){ System.out.println(str); } //System.out.println(Arrays.toString(purpose)); } }