-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path210124_BOJ_3980.cpp
More file actions
56 lines (38 loc) · 785 Bytes
/
Copy path210124_BOJ_3980.cpp
File metadata and controls
56 lines (38 loc) · 785 Bytes
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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int C = 0;
int Max = 0;
vector<vector<int>> v;
void findBest(vector<bool> position, int sum, int cnt) {
if (cnt == 11 && Max < sum) {
Max = sum;
return;
}
for (int j = 0; j < 11; ++j) {
if (position[j] || v[cnt][j] == 0)
continue;
position[j] = true;
findBest(position, sum + v[cnt][j], cnt + 1);
position[j] = false;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
cin >> C;
while (C--) {
v.assign(11, vector<int>(11));
for (int i = 0; i < 11; ++i) {
for (int j = 0; j < 11; ++j) {
cin >> v[i][j];
}
}
Max = 0;
vector<bool> position(11, false);
findBest(position, 0, 0);
cout << Max << "\n";
}
return 0;
}