結果

問題 No.323 yuki国
ユーザー kou6839kou6839
提出日時 2015-12-16 00:53:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 591 ms / 5,000 ms
コード長 1,613 bytes
コンパイル時間 2,291 ms
コンパイル使用メモリ 74,816 KB
実行使用メモリ 99,988 KB
最終ジャッジ日時 2023-09-10 21:15:35
合計ジャッジ時間 14,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,612 KB
testcase_01 AC 128 ms
55,380 KB
testcase_02 AC 127 ms
55,748 KB
testcase_03 AC 131 ms
55,648 KB
testcase_04 AC 131 ms
55,908 KB
testcase_05 AC 177 ms
58,328 KB
testcase_06 AC 163 ms
58,108 KB
testcase_07 AC 132 ms
55,652 KB
testcase_08 AC 483 ms
97,656 KB
testcase_09 AC 355 ms
97,384 KB
testcase_10 AC 128 ms
55,612 KB
testcase_11 AC 132 ms
55,840 KB
testcase_12 AC 130 ms
55,964 KB
testcase_13 AC 318 ms
97,304 KB
testcase_14 AC 441 ms
97,420 KB
testcase_15 AC 304 ms
97,356 KB
testcase_16 AC 460 ms
99,892 KB
testcase_17 AC 364 ms
97,512 KB
testcase_18 AC 154 ms
64,496 KB
testcase_19 AC 456 ms
78,148 KB
testcase_20 AC 204 ms
86,440 KB
testcase_21 AC 591 ms
97,912 KB
testcase_22 AC 300 ms
95,616 KB
testcase_23 AC 554 ms
99,988 KB
testcase_24 AC 225 ms
86,516 KB
testcase_25 AC 343 ms
97,608 KB
testcase_26 AC 220 ms
86,456 KB
testcase_27 AC 506 ms
97,644 KB
testcase_28 AC 355 ms
97,696 KB
testcase_29 AC 370 ms
97,680 KB
testcase_30 AC 135 ms
53,680 KB
testcase_31 AC 146 ms
55,748 KB
testcase_32 AC 165 ms
55,872 KB
testcase_33 AC 153 ms
55,588 KB
testcase_34 AC 190 ms
58,172 KB
testcase_35 AC 146 ms
55,804 KB
testcase_36 AC 158 ms
55,692 KB
testcase_37 AC 137 ms
53,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static class snow{
		int x,y,unko;
		public snow(int x,int y,int unko) {
			// TODO Auto-generated constructor stub
			this.x = x;
			this.y = y;
			this.unko = unko;
		}
	}
	static long gcd(long a,long b){
		return b == 0 ? a : gcd(b, a%b);
	}
	static long lcm(long a, long b){
		return a*b/gcd(a, b);
	}
	static int[] dx = {1,0,-1,0};
	static int[] dy = {0,1,0,-1};
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int b = sc.nextInt();
		int gx = sc.nextInt();
		int gy = sc.nextInt();
		boolean[][] map = new boolean[x][y];
		for(int i=0;i<x;i++){
			String tmp = sc.next();
			for(int j=0;j<y;j++){
				if(tmp.charAt(j)=='*') map[i][j]=true;
			}
		}
		boolean[][][] checked = new boolean[x][y][10000];
		Queue<snow> queue = new LinkedList<>();
		queue.add(new snow(sx, sy, a));
		int count = 0;
		while(!queue.isEmpty()){
			snow now = queue.poll();
			count++;
			if(count>3000000) break;
			if(now.x == gx && now.y == gy && now.unko == b){
				System.out.println("Yes");
				return;
			}
			for(int i=0;i<4;i++){
				int nextx = now.x+dx[i];
				int nexty = now.y+dy[i];
				if(nextx>=0 &&nextx<x && nexty>=0 && nexty<y){
					int nextunk = now.unko+ (map[nextx][nexty]?1:-1);
					if(nextunk<=0 || nextunk > 5000|| checked[nextx][nexty][nextunk]) continue;
					queue.add(new snow(nextx, nexty, nextunk));
					checked[nextx][nexty][nextunk]=true;
				}
			}
		}
		System.out.println("No");
		
	}
}
0