1547号
5842 ワード
https://zzang9ha.tistory.com/247
このまま解けば
私の恨み
このまま解けば
私の恨み
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
// 1 2 3
int swap;
Integer[] array = {1, 2, 3};
for(int i = 0; i < num ; i++){
int one = sc.nextInt(); // 3
int two = sc.nextInt(); // 1
swap = array[one - 1] ; // swap = 3 {1, 2, 3]
array[one-1] = array[two-1]; // {1,2,1}
array[two-1] = swap; // {3,2,1}
}
int idx = Arrays.asList(array).indexOf(1);
System.out.println(idx+1);
}
}
Reference
この問題について(1547号), 我々は、より多くの情報をここで見つけました https://velog.io/@cwangg897/1547번テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol