Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6c21bc9

Browse files
authored
Merge pull request #213 from GreatAlgorithm-Study/dahye
문제 풀이 못한거 마무리
2 parents e801132 + d6aa6ac commit 6c21bc9

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

‎CodeTree/2019-2020년/DH_윷놀이_사기단.java‎

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ public class DH_윷놀이_사기단 {
88
static class Horse {
99
int r, c;
1010
public Horse() {}
11-
@Override
12-
public String toString() {
13-
return "Horse [r=" + r + ", c=" + c + "]";
14-
}
1511
}
1612
static int maxResult;
1713
static boolean[] v;
1814
static Horse[] horses;
15+
static Set<Integer> moreOne;
1916

2017
public static void main(String[] args) throws Exception {
2118
horses = new Horse[5];
@@ -28,6 +25,14 @@ public static void main(String[] args) throws Exception {
2825
{20, 22, 24, 25, 30, 35, 40, 41},
2926
{30, 28, 27, 26, 25, 30, 35, 40, 41}};
3027

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+
3136
initInput();
3237
solution();
3338
System.out.println(maxResult);
@@ -55,6 +60,7 @@ static void func(int depth, int result) {
5560
int nr = currentR;
5661
int nc = currentC + arr[depth];
5762

63+
boolean canGo = true;
5864
if(nc >= map[nr].length) {
5965
nc = map[nr].length - 1;
6066
v[i] = true;
@@ -65,22 +71,29 @@ static void func(int depth, int result) {
6571
nc = 0;
6672
}
6773

68-
boolean canGo = true;
6974

7075
for(int j = 1; j < 5; j++) {
7176
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+
}
7890
}
7991
}
8092

81-
if(!canGo) continue;
8293
}
8394

95+
if(!canGo) continue;
96+
8497
horses[i].r = nr;
8598
horses[i].c = nc;
8699

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /