結果

問題 No.323 yuki国
ユーザー kou6839kou6839
提出日時 2015-12-16 00:51:55
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,598 bytes
コンパイル時間 4,491 ms
コンパイル使用メモリ 75,764 KB
実行使用メモリ 749,092 KB
最終ジャッジ日時 2023-10-14 10:32:00
合計ジャッジ時間 23,708 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
62,560 KB
testcase_01 AC 123 ms
56,180 KB
testcase_02 AC 140 ms
68,696 KB
testcase_03 AC 189 ms
135,840 KB
testcase_04 AC 129 ms
65,028 KB
testcase_05 AC 333 ms
88,908 KB
testcase_06 AC 273 ms
70,360 KB
testcase_07 AC 139 ms
79,852 KB
testcase_08 MLE -
testcase_09 MLE -
testcase_10 AC 124 ms
55,924 KB
testcase_11 AC 124 ms
57,740 KB
testcase_12 AC 127 ms
58,192 KB
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
testcase_27 MLE -
testcase_28 MLE -
testcase_29 MLE -
testcase_30 AC 134 ms
68,276 KB
testcase_31 RE -
testcase_32 AC 289 ms
64,876 KB
testcase_33 RE -
testcase_34 AC 313 ms
77,064 KB
testcase_35 AC 129 ms
60,424 KB
testcase_36 AC 284 ms
64,892 KB
testcase_37 AC 130 ms
62,824 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][1000000];
		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 || checked[nextx][nexty][nextunk]) continue;
					queue.add(new snow(nextx, nexty, nextunk));
					checked[nextx][nexty][nextunk]=true;
				}
			}
		}
		System.out.println("No");
		
	}
}
0