結果
問題 | No.323 yuki国 |
ユーザー | ki_ki33 |
提出日時 | 2015-12-16 17:15:54 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 3,228 bytes |
コンパイル時間 | 2,211 ms |
コンパイル使用メモリ | 82,904 KB |
実行使用メモリ | 68,964 KB |
最終ジャッジ日時 | 2023-10-14 10:50:14 |
合計ジャッジ時間 | 48,192 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 120 ms
56,232 KB |
testcase_01 | AC | 120 ms
56,380 KB |
testcase_02 | AC | 113 ms
56,020 KB |
testcase_03 | AC | 154 ms
56,972 KB |
testcase_04 | AC | 118 ms
55,596 KB |
testcase_05 | AC | 133 ms
56,284 KB |
testcase_06 | AC | 118 ms
56,356 KB |
testcase_07 | AC | 133 ms
55,908 KB |
testcase_08 | TLE | - |
testcase_09 | AC | 3,159 ms
67,304 KB |
testcase_10 | AC | 119 ms
56,064 KB |
testcase_11 | AC | 119 ms
56,432 KB |
testcase_12 | AC | 121 ms
56,324 KB |
testcase_13 | AC | 159 ms
60,784 KB |
testcase_14 | AC | 165 ms
61,288 KB |
testcase_15 | AC | 3,959 ms
66,800 KB |
testcase_16 | TLE | - |
testcase_17 | AC | 204 ms
62,376 KB |
testcase_18 | AC | 169 ms
58,940 KB |
testcase_19 | AC | 257 ms
62,008 KB |
testcase_20 | AC | 210 ms
62,956 KB |
testcase_21 | AC | 216 ms
63,604 KB |
testcase_22 | AC | 197 ms
62,380 KB |
testcase_23 | AC | 218 ms
62,200 KB |
testcase_24 | AC | 3,702 ms
64,836 KB |
testcase_25 | AC | 4,121 ms
64,544 KB |
testcase_26 | AC | 3,517 ms
67,012 KB |
testcase_27 | AC | 1,933 ms
65,996 KB |
testcase_28 | AC | 4,390 ms
66,540 KB |
testcase_29 | AC | 4,266 ms
68,048 KB |
testcase_30 | AC | 122 ms
55,612 KB |
testcase_31 | AC | 119 ms
56,428 KB |
testcase_32 | AC | 123 ms
56,124 KB |
testcase_33 | AC | 121 ms
55,884 KB |
testcase_34 | AC | 125 ms
55,728 KB |
testcase_35 | AC | 122 ms
56,000 KB |
testcase_36 | AC | 121 ms
56,124 KB |
testcase_37 | AC | 120 ms
55,884 KB |
ソースコード
import java.awt.Point; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.io.BufferedInputStream; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentSkipListSet; import javax.swing.ImageIcon; public class Main { static final long C = 1000000007; static final int CY = 1000000000; //long[] F; public void calc() { long fTime = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(); BufferedInputStream bs = new BufferedInputStream(System.in); Scanner sc = new Scanner(bs); int h = sc.nextInt(); int w = sc.nextInt(); int f = sc.nextInt(); Point fp = new Point(sc.nextInt(), sc.nextInt()); g = sc.nextInt(); gp = new Point(sc.nextInt(), sc.nextInt()); map = new char[h][]; for (int i=0; i < h; i++) { map[i] = sc.next().toCharArray(); } memo = new boolean[h][w][1501]; boolean ans = false; memo[fp.x][fp.y][f] = true; msd(fp.x, fp.y); ans = memo[gp.x][gp.y][g]; System.out.println(ans?"Yes":"No"); } //static int N = 1500; boolean[][][] memo ; char[][] map; int g; Point gp; void msd(int x, int y) { if (memo[gp.x][gp.y][g]) { return; } int nx = x+1, ny = y; boolean isUp = false; boolean isDown = false; if (isIn(nx, ny)) { char nc = map[nx][ny]; if (nc == map[x][y]) { if (nc == '.' ) { isDown = true; }else { isUp = true; } } } nx = x-1;ny = y; if (isIn(nx, ny)) { char nc = map[nx][ny]; if (nc == map[x][y]) { if (nc == '.' ) { isDown = true; }else { isUp = true; } } } nx = x;ny = y+1; if (isIn(nx, ny)) { char nc = map[nx][ny]; if (nc == map[x][y]) { if (nc == '.' ) { isDown = true; }else { isUp = true; } } } nx = x;ny = y-1; if (isIn(nx, ny)) { char nc = map[nx][ny]; if (nc == map[x][y]) { if (nc == '.' ) { isDown = true; }else { isUp = true; } } } if (isDown) { int max = 0; for (int i=1499;i >= 0; i--) { if (memo[x][y][i] ){ max = i; break; } } for (int i=max;i >= 0; i-=2) { memo[x][y][i]= true; } } if (isUp ) { int max = 1500; for (int i=0;i < 1500; i++) { if (memo[x][y][i] ){ max = i; break; } } for (int i=max;i < 1500; i+=2) { memo[x][y][i]= true; } } nx = x+1;ny = y; check(x, y, nx, ny); nx = x-1;ny = y; check(x, y, nx, ny); nx = x;ny = y+1; check(x, y, nx, ny); nx = x;ny = y-1; check(x, y, nx, ny); } private void check(int x, int y, int nx, int ny) { int add; if (isIn(nx, ny)) { char nc = map[nx][ny]; add = nc == '.'?-1:1; boolean flag = false; for (int i=1; i < 1500; i++) { if (memo[x][y][i]) { if (!memo[nx][ny][i+add]) { memo[nx][ny][i+add] = true; flag = true; } } } if (flag) { msd(nx, ny); } } } boolean isIn(int x, int y) { return !(x < 0 || y < 0 || map.length <= x || map[0].length <= y); } public static void main(String[] args) { Main main = new Main(); main.calc(); } }