-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathColurBlindness.java
More file actions
90 lines (67 loc) · 2.07 KB
/
ColurBlindness.java
File metadata and controls
90 lines (67 loc) · 2.07 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package spell_check;
import org.junit.jupiter.api.Test;
import java.io.*;
import java.util.StringTokenizer;
public class colourblindness {
static InputReader r;
static int T;
static char R = 'R';
static StringBuilder answer = new StringBuilder();
private static void solution() throws IOException {
// R G B
// G==B
int col = r.nextInt();
String r1 = r.nextLine();
String r2 = r.nextLine();
// 오른쪽으로 전진
for (int i = 0; i < col; i++) {
// 위 아래가 같으면 오른쪽으로
if (check(r1.charAt(i), r2.charAt(i))) {
continue;
}
answer.append("NO\n");
return;
}
answer.append("YES\n");
}
static boolean check(char a, char b) {
if (a == b) return true;
return a != R && b != R;
}
private static void input() throws IOException {
r = new InputReader();
T = r.nextInt();
}
@Test
public static void main(String[] args) throws IOException {
input();
for (int t = 0; t < T; t++) {
solution();
}
System.out.println(answer.toString());
}
private static class InputReader {
StringTokenizer st;
BufferedReader r;
public InputReader(String filePath) throws FileNotFoundException {
this(new FileReader(filePath));
}
public InputReader() {
this(new InputStreamReader(System.in));
}
private InputReader(InputStreamReader reader) {
r = new BufferedReader(reader);
st = new StringTokenizer("");
}
public int nextInt() throws IOException {
if (!st.hasMoreTokens()) st = new StringTokenizer(r.readLine());
return Integer.parseInt(st.nextToken());
}
public char[] nextCharArr() throws IOException {
return r.readLine().toCharArray();
}
public String nextLine() throws IOException {
return r.readLine();
}
}
}