From d6aa6ac7648b8424731352918d4846ec1c1d493c Mon Sep 17 00:00:00 2001 From: KodaHye Date: 2024年12月22日 01:04:59 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B3=A0=EB=8B=A4=ED=98=9C:=20[CT]=20=EC=9C=B7?= =?UTF-8?q?=EB=86=80=EC=9D=B4=20=EC=82=AC=EA=B8=B0=EB=8B=A8=5F241216?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354円202円254円352円270円260円353円213円250円.java" | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git "a/CodeTree/2019-2020353円205円204円/DH_354円234円267円353円206円200円354円235円264円_354円202円254円352円270円260円353円213円250円.java" "b/CodeTree/2019-2020353円205円204円/DH_354円234円267円353円206円200円354円235円264円_354円202円254円352円270円260円353円213円250円.java" index 2ebb7e70..c53f7565 100644 --- "a/CodeTree/2019-2020353円205円204円/DH_354円234円267円353円206円200円354円235円264円_354円202円254円352円270円260円353円213円250円.java" +++ "b/CodeTree/2019-2020353円205円204円/DH_354円234円267円353円206円200円354円235円264円_354円202円254円352円270円260円353円213円250円.java" @@ -8,14 +8,11 @@ public class DH_윷놀이_사기단 { static class Horse { int r, c; public Horse() {} - @Override - public String toString() { - return "Horse [r=" + r + ", c=" + c + "]"; - } } static int maxResult; static boolean[] v; static Horse[] horses; + static Set moreOne; public static void main(String[] args) throws Exception { horses = new Horse[5]; @@ -28,6 +25,14 @@ public static void main(String[] args) throws Exception { {20, 22, 24, 25, 30, 35, 40, 41}, {30, 28, 27, 26, 25, 30, 35, 40, 41}}; + moreOne = new HashSet(); + moreOne.add(16); + moreOne.add(22); + moreOne.add(24); + moreOne.add(26); + moreOne.add(28); + moreOne.add(30); + initInput(); solution(); System.out.println(maxResult); @@ -55,6 +60,7 @@ static void func(int depth, int result) { int nr = currentR; int nc = currentC + arr[depth]; + boolean canGo = true; if(nc>= map[nr].length) { nc = map[nr].length - 1; v[i] = true; @@ -65,22 +71,29 @@ static void func(int depth, int result) { nc = 0; } - boolean canGo = true; for(int j = 1; j < 5; j++) { if(j == i) continue; - if(map[horses[i].r][horses[i].c] == 0 || map[horses[j].r][horses[j].c] == 0) continue; - if(map[horses[i].r][horses[i].c] == 41 || map[horses[j].r][horses[j].c] == 41) continue; - - if(nr == horses[j].r && nc == horses[j].c) { - canGo = false; - break; + if(map[nr][nc] == 0 || map[horses[j].r][horses[j].c] == 0) continue; + if(map[nr][nc] == 41 || map[horses[j].r][horses[j].c] == 41) continue; + + if(moreOne.contains(map[nr][nc])) { + if(horses[j].r == nr && horses[j].c == nc) { + canGo = false; + break; + } + } else { + if(map[nr][nc] == map[horses[j].r][horses[j].c]) { + canGo = false; + break; + } } } - if(!canGo) continue; } + if(!canGo) continue; + horses[i].r = nr; horses[i].c = nc;

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