-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path규영이와 인영이의 카드게임.java
More file actions
67 lines (56 loc) · 1.7 KB
/
Copy path규영이와 인영이의 카드게임.java
File metadata and controls
67 lines (56 loc) · 1.7 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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;
public class Solution {
static Integer[] inyoung;
static Integer[] inyoungPerm;
static Integer[] kyu;
static Integer[] numbers;
static int totalCnt;
static int win;
static int lose;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
StringBuilder sb = new StringBuilder();
int TC = Integer.parseInt(br.readLine());
for (int t = 1; t <= TC; t++) {
HashSet<Integer> numbers = new HashSet<>();
kyu = new Integer[9];
inyoung = new Integer[9];
inyoungPerm = new Integer[9];
win = 0;
lose = 0;
st = new StringTokenizer(br.readLine());
for (int i = 1; i < 19; i++) numbers.add(i);
for (int i = 0; i < 9; i++){
kyu[i] = Integer.parseInt(st.nextToken());
numbers.remove(kyu[i]);
}
inyoung = numbers.toArray(new Integer[9]);
//=========================input setting=========================================================
perm(0,0);
sb.append("#").append(t).append(" ").append(win).append(" ").append(lose).append("\n");
}
System.out.println(sb);
}
private static void perm(int cnt, int flag) {
if(cnt == 9) {
totalCnt++;
int Knum = 0, Inum = 0;
for (int i = 0; i < 9; i++) {
if(kyu[i] < inyoungPerm[i]) Inum += kyu[i] + inyoungPerm[i];
else Knum += kyu[i] + inyoungPerm[i];
}
if(Knum > Inum) win++;
else if (Knum < Inum) lose++;
return;
}
for (int i = 0; i < 9; i++) {
if((flag & (1 << i)) != 0) continue;
inyoungPerm[cnt] = inyoung[i];
perm(cnt + 1, (flag | 1 << i));
}
}
}