結果

問題 No.323 yuki国
ユーザー ki_ki33ki_ki33
提出日時 2015-12-16 16:08:14
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,392 bytes
コンパイル時間 2,490 ms
コンパイル使用メモリ 83,944 KB
実行使用メモリ 66,324 KB
最終ジャッジ日時 2023-10-14 10:47:22
合計ジャッジ時間 11,838 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,068 KB
testcase_01 AC 192 ms
57,472 KB
testcase_02 AC 121 ms
56,120 KB
testcase_03 AC 977 ms
57,164 KB
testcase_04 AC 258 ms
56,824 KB
testcase_05 AC 431 ms
57,744 KB
testcase_06 AC 185 ms
56,648 KB
testcase_07 AC 156 ms
57,128 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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");

	}

	boolean[][][] memo ;
	char[][] map;
	int g;
	Point gp;

	void msd(int x, int y) {
		int nx = x+1,ny = y;
		int add ;
		if (isIn(nx, ny)) {
			add = map[nx][ny] == '.'?-1:1;

			for (int i=1; i < 1500; i++) {
				if (memo[x][y][i]) {
					if (!memo[nx][ny][i+add]) {
						memo[nx][ny][i+add] = true;
						msd(nx, ny);
					}
				}
			}
		}
		nx = x-1;ny = y;
		if (isIn(nx, ny)) {
			add = map[nx][ny] == '.'?-1:1;
			for (int i=1; i < 1500; i++) {
				if (memo[x][y][i]) {
					if (!memo[nx][ny][i+add]) {
						memo[nx][ny][i+add] = true;
						msd(nx, ny);
					}
				}
			}
		}
		nx = x;ny = y+1;
		
		if (isIn(nx, ny)) {
			add = map[nx][ny] == '.'?-1:1;
			for (int i=1; i < 1500; i++) {
				if (memo[x][y][i]) {
					if (!memo[nx][ny][i+add]) {
						memo[nx][ny][i+add] = true;
						msd(nx, ny);
					}
				}
			}
		}
		nx = x;ny = y-1;
		
		if (isIn(nx, ny)) {
			add = map[nx][ny] == '.'?-1:1;
			for (int i=1; i < 1500; i++) {
				if (memo[x][y][i]) {
					if (!memo[nx][ny][i+add]) {
						memo[nx][ny][i+add] = true;
						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();

	}
}
0