8000 Merge pull request #263 from SciEm/17281_1.cpp · JeeeunOh/basic-algo-lecture@717f28d · GitHub
[go: up one dir, main page]

Skip to content

Commit 717f28d

Browse files
Merge pull request encrypted-def#263 from SciEm/17281_1.cpp
Update 17281_1.cpp
2 parents 4f4c4eb + 4adae65 commit 717f28d

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

0x0D/solutions/17281_1.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
}

0 commit comments

Comments
 (0)
0