Skip to content

Commit 36d2b0c

Browse files
author
SciEm
committed
Update 17281.cpp
1 parent 8057d96 commit 36d2b0c

File tree

1 file changed

+60
-5
lines changed

1 file changed

+60
-5
lines changed

0x0D/solutions/17281.cpp

+60-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,66 @@
1-
// Authored by : BaaaaaaaaaaarkingDog
1+
// Authored by : SciEm
22
// Co-authored by : -
3-
// http://boj.kr/****************
3+
// http://boj.kr/35a08f4f67bc4df2803469b472ffebe4
44
#include <bits/stdc++.h>
55
using namespace std;
66

7-
int main(void){
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+
void brute(int k) {
38+
if (k == 9) {
39+
run();
40+
return;
41+
}
42+
if (k == 3) {
43+
brute(k + 1);
44+
return;
45+
}
46+
for (int i = 1; i < 9; i++) {
47+
if (isused[i]) continue;
48+
order[k] = i;
49+
isused[i] = true;
50+
brute(k + 1);
51+
isused[i] = false;
52+
}
53+
}
54+
55+
int main() {
856
ios::sync_with_stdio(0);
957
cin.tie(0);
10-
11-
}
58+
59+
cin >> n;
60+
for (int i = 0; i < n; i++)
61+
for (int j = 0; j < 9; j++)
62+
cin >> board[i][j];
63+
64+
brute(0);
65+
cout << ans;
66+
}

0 commit comments

Comments
 (0)