File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.* ;
3+ import java.util.* ;
4+
5+ public class Main {
6+ static int [][] player = new int [11 ][11 ];
7+ static boolean [] visited = new boolean [11 ];
8+ static int res;
9+
10+ public static void main (String [] args ) throws Exception {
11+ BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
12+ StringTokenizer st;
13+
14+ int T = Integer . parseInt(br. readLine());
15+
16+ for (int t = 0 ; t < T ; t++ ) {
17+ for (int i = 0 ; i < 11 ; i++ ) {
18+ st = new StringTokenizer (br. readLine());
19+ for (int j = 0 ; j < 11 ; j++ ) {
20+ player[i][j] = Integer . parseInt(st. nextToken());
21+ }
22+ }
23+
24+ res = 0 ;
25+ dfs(0 , 0 );
26+ System . out. println(res);
27+ }
28+ }
29+
30+ static void dfs (int pos , int temp ) {
31+ if (pos == 11 ) {
32+ res = Math . max(res, temp);
33+ return ;
34+ }
35+
36+ for (int i = 0 ; i < 11 ; i++ ) {
37+ if (! visited[i] && player[i][pos] > 0 ) {
38+ visited[i] = true ;
39+ dfs(pos + 1 , temp + player[i][pos]);
40+ visited[i] = false ;
41+ }
42+ }
43+ }
44+ }
45+ ```
You can’t perform that action at this time.
0 commit comments