@@ -8,14 +8,11 @@ public class DH_윷놀이_사기단 {
8
8
static class Horse {
9
9
int r , c ;
10
10
public Horse () {}
11
- @ Override
12
- public String toString () {
13
- return "Horse [r=" + r + ", c=" + c + "]" ;
14
- }
15
11
}
16
12
static int maxResult ;
17
13
static boolean [] v ;
18
14
static Horse [] horses ;
15
+ static Set <Integer > moreOne ;
19
16
20
17
public static void main (String [] args ) throws Exception {
21
18
horses = new Horse [5 ];
@@ -28,6 +25,14 @@ public static void main(String[] args) throws Exception {
28
25
{20 , 22 , 24 , 25 , 30 , 35 , 40 , 41 },
29
26
{30 , 28 , 27 , 26 , 25 , 30 , 35 , 40 , 41 }};
30
27
28
+ moreOne = new HashSet <Integer >();
29
+ moreOne .add (16 );
30
+ moreOne .add (22 );
31
+ moreOne .add (24 );
32
+ moreOne .add (26 );
33
+ moreOne .add (28 );
34
+ moreOne .add (30 );
35
+
31
36
initInput ();
32
37
solution ();
33
38
System .out .println (maxResult );
@@ -55,6 +60,7 @@ static void func(int depth, int result) {
55
60
int nr = currentR ;
56
61
int nc = currentC + arr [depth ];
57
62
63
+ boolean canGo = true ;
58
64
if (nc >= map [nr ].length ) {
59
65
nc = map [nr ].length - 1 ;
60
66
v [i ] = true ;
@@ -65,22 +71,29 @@ static void func(int depth, int result) {
65
71
nc = 0 ;
66
72
}
67
73
68
- boolean canGo = true ;
69
74
70
75
for (int j = 1 ; j < 5 ; j ++) {
71
76
if (j == i ) continue ;
72
- if (map [horses [i ].r ][horses [i ].c ] == 0 || map [horses [j ].r ][horses [j ].c ] == 0 ) continue ;
73
- if (map [horses [i ].r ][horses [i ].c ] == 41 || map [horses [j ].r ][horses [j ].c ] == 41 ) continue ;
74
-
75
- if (nr == horses [j ].r && nc == horses [j ].c ) {
76
- canGo = false ;
77
- break ;
77
+ if (map [nr ][nc ] == 0 || map [horses [j ].r ][horses [j ].c ] == 0 ) continue ;
78
+ if (map [nr ][nc ] == 41 || map [horses [j ].r ][horses [j ].c ] == 41 ) continue ;
79
+
80
+ if (moreOne .contains (map [nr ][nc ])) {
81
+ if (horses [j ].r == nr && horses [j ].c == nc ) {
82
+ canGo = false ;
83
+ break ;
84
+ }
85
+ } else {
86
+ if (map [nr ][nc ] == map [horses [j ].r ][horses [j ].c ]) {
87
+ canGo = false ;
88
+ break ;
89
+ }
78
90
}
79
91
}
80
92
81
- if (!canGo ) continue ;
82
93
}
83
94
95
+ if (!canGo ) continue ;
96
+
84
97
horses [i ].r = nr ;
85
98
horses [i ].c = nc ;
86
99
0 commit comments