結果

問題 No.323 yuki国
ユーザー 37zigen37zigen
提出日時 2016-03-14 03:21:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 591 ms / 5,000 ms
コード長 1,478 bytes
コンパイル時間 3,939 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 100,244 KB
最終ジャッジ日時 2023-09-10 21:26:51
合計ジャッジ時間 15,998 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,004 KB
testcase_01 AC 126 ms
55,876 KB
testcase_02 AC 141 ms
56,004 KB
testcase_03 AC 126 ms
55,592 KB
testcase_04 AC 124 ms
55,696 KB
testcase_05 AC 200 ms
58,800 KB
testcase_06 AC 171 ms
56,456 KB
testcase_07 AC 123 ms
55,620 KB
testcase_08 AC 475 ms
97,740 KB
testcase_09 AC 338 ms
97,384 KB
testcase_10 AC 139 ms
56,332 KB
testcase_11 AC 128 ms
55,644 KB
testcase_12 AC 125 ms
55,664 KB
testcase_13 AC 315 ms
97,540 KB
testcase_14 AC 442 ms
97,748 KB
testcase_15 AC 305 ms
97,856 KB
testcase_16 AC 454 ms
97,520 KB
testcase_17 AC 357 ms
97,804 KB
testcase_18 AC 154 ms
64,816 KB
testcase_19 AC 470 ms
78,408 KB
testcase_20 AC 202 ms
86,664 KB
testcase_21 AC 591 ms
98,132 KB
testcase_22 AC 274 ms
87,168 KB
testcase_23 AC 562 ms
100,100 KB
testcase_24 AC 261 ms
87,320 KB
testcase_25 AC 401 ms
97,844 KB
testcase_26 AC 240 ms
87,112 KB
testcase_27 AC 514 ms
100,244 KB
testcase_28 AC 355 ms
97,552 KB
testcase_29 AC 369 ms
97,760 KB
testcase_30 AC 141 ms
54,660 KB
testcase_31 AC 158 ms
55,540 KB
testcase_32 AC 166 ms
56,008 KB
testcase_33 AC 156 ms
55,672 KB
testcase_34 AC 174 ms
56,872 KB
testcase_35 AC 139 ms
55,716 KB
testcase_36 AC 157 ms
55,900 KB
testcase_37 AC 124 ms
55,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayDeque;
import java.util.Date;
import java.util.Queue;
import java.util.Scanner;
public class main{
	static class snow{
		int x,y,z;
		snow(int x,int y,int z){
			this.x=x;
			this.y=y;
			this.z=z;
		}
	}
	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);
		long exec_time=new Date().getTime();
		int h=sc.nextInt();
		int w=sc.nextInt();
		int a=sc.nextInt();
		int si=sc.nextInt();
		int sj=sc.nextInt();
		int b=sc.nextInt();
		int gi=sc.nextInt();
		int gj=sc.nextInt();
		
		boolean[][] map=new boolean[h][w];
		for(int i=0;i<h;i++){
			String tmp=sc.next();
			for(int j=0;j<w;j++){
				if(tmp.charAt(j)=='*')map[i][j]=true;
			}
		}
		boolean[][][] used=new boolean[h][w][10000];
		Queue<snow> q=new ArrayDeque<>();
		q.add(new snow(si,sj,a));
		int count=0;
		while(!q.isEmpty()){
			snow now=q.poll();
			count++;
			if(count>3000000)break;
			if(now.x==gi&&now.y==gj&&now.z==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<h&&nexty>=0&&nexty<w){
					int nextz=now.z+(map[nextx][nexty]?1:-1);
					if(nextz<=0||nextz>5000||used[nextx][nexty][nextz])continue;
					q.add(new snow(nextx,nexty,nextz));
					used[nextx][nexty][nextz]=true;
				}
			}
		}
		System.out.println("No");

			System.err.println(new Date().getTime()-exec_time+"ms");		
		}
	}


0