-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboj2503.java
74 lines (62 loc) · 1.58 KB
/
boj2503.java
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
package java_boj;
import java.util.*;
class Baseball {
static LinkedList<String> curNum = new LinkedList<>();
static LinkedList<String> ans = new LinkedList<>();
static {
for(int i = 1; i<=9; i++) {
for(int j = 1; j <= 9; j++) {
for(int k = 1; k <= 9; k++) {
if(i == j || j == k || i == k) continue;
String s = i+"" + j + "" + k + "";
curNum.add(s);
}
}
}
}
static void check(String compS, int strike, int ball) {
int i = 0;
while (i < curNum.size()) {
String s = curNum.get(i);
// System.out.println(s);
int st_count = 0;
int ball_count = 0;
for(int j = 0; j<3; j++) {
for(int k = 0; k < 3; k++) {
if(compS.charAt(j) == s.charAt(k) && j == k) {
st_count++;
continue;
}
else if(compS.charAt(j) == s.charAt(k) && j != k) {
ball_count++;
continue;
}
}
}
if (st_count != strike || ball_count != ball) {
curNum.remove(i);
i -= 1;
}
i += 1;
}
ans = curNum;
//System.out.println("size : " + curNum.size());
}
}
public class boj2503 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
for(int i = 0; i<n; i++) {
String s = sc.nextLine();
if (Integer.parseInt(s.split(" ")[1]) == 3) {
break;
}
Baseball.check(s.split(" ")[0], Integer.parseInt(s.split(" ")[1])
, Integer.parseInt(s.split(" ")[2]));
}
// System.out.println(Baseball.ans);
System.out.println(Baseball.ans.size());
}
}