Dev.baelanche

[백준 1547] 공 본문

Data Structure & Algorithm/PS - JAVA

[백준 1547] 공

baelanche 2019. 6. 29. 17:31
반응형

 

야바위를 할때마다 자리를 스왑해주면된다.

 

공이 사라지는 경우는 없다;;;;

 

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int m = sc.nextInt();
        int a[] = new int[4];
        a[1] = 1;
        
        while(m-->0) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            swap(a, x, y);
        }
        
        for(int i=1; i<=3; i++)
            if(a[i] == 1)
                System.out.println(i);
    }
    
    public static void swap(int a[], int x, int y) {
        int temp = a[x];
        a[x] = a[y];
        a[y] = temp;
    }
}
반응형

'Data Structure & Algorithm > PS - JAVA' 카테고리의 다른 글

[백준 1009] 분산처리  (0) 2019.06.29
[백준 2979] 트럭 주차  (0) 2019.06.29
[백준 14500] 테트로미노  (0) 2019.06.29
[백준 6603] 로또  (0) 2019.06.29
[백준 11866] 조세퍼스 문제 0  (0) 2019.06.29
Comments