Home 13413번(오셀로 재배치)
Post
Cancel

13413번(오셀로 재배치)

해결

  • "오셀로 재배치"

코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        int T = Integer.parseInt(br.readLine());

        for(int i = 0; i < T; i++) {
            int N = Integer.parseInt(br.readLine());
            String str1 = br.readLine();
            String str2 = br.readLine();
            int white = 0;
            int black = 0;
            for(int j = 0; j < N; j++) {
                if(str1.charAt(j) != str2.charAt(j)){
                    if(str1.charAt(j) == 'W') white++;
                    else black++;
                }
            }
            System.out.println(Math.max(white,black));
        }
    }

}

참고

This post is licensed under CC BY 4.0 by the author.