File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Authored by : SciEm
2
+ // Co-authored by : -
3
+ // http://boj.kr/885bdec0716d40568722fae2cb8b2d84
4
+ #include < bits/stdc++.h>
5
+ using namespace std ;
6
+
7
+ int board[51 ][9 ];
8
+ int order[9 ];
9
+ bool isused[9 ];
10
+ int n, ans;
11
+
12
+ void run () {
13
+ int score = 0 ;
14
+ int idx = 0 ;
15
+ for (int inning = 0 ; inning < n; inning++) {
16
+ bool bases[4 ] = {};
17
+ int out = 0 ;
18
+ while (out < 3 ) {
19
+ bases[0 ] = true ;
20
+ int move = board[inning][order[idx++]];
21
+ if (idx == 9 ) idx = 0 ;
22
+ if (!move) {
23
+ out++;
24
+ continue ;
25
+ }
26
+ for (int i = 3 ; i >= 0 ; i--) {
27
+ if (!bases[i]) continue ;
28
+ if (i + move >= 4 ) score++;
29
+ else bases[i + move] = true ;
30
+ bases[i] = false ;
31
+ }
32
+ }
33
+ }
34
+ ans = max (ans, score);
35
+ }
36
+
37
+ int main () {
38
+ ios::sync_with_stdio (0 );
39
+ cin.tie (0 );
40
+
41
+ cin >> n;
42
+ for (int i = 0 ; i < n; i++)
43
+ for (int j = 0 ; j < 9 ; j++)
44
+ cin >> board[i][j];
<
79AA
/code>
45
+
46
+ int arr[8 ];
47
+ for (int i = 0 ; i < 8 ; i++)
48
+ arr[i] = i + 1 ;
49
+ order[3 ] = 0 ;
50
+
51
+ do {
52
+ copy (arr, arr + 3 , order);
53
+ copy (arr + 3 , arr + 8 , order + 4 );
54
+ run ();
55
+ } while (next_permutation (arr, arr + 8 ));
56
+ cout << ans;
57
+ }
You can’t perform that action at this time.
0 commit comments