結果

問題 No.323 yuki国
ユーザー kuuso1kuuso1
提出日時 2016-06-12 04:44:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 344 ms / 5,000 ms
コード長 1,805 bytes
コンパイル時間 3,625 ms
コンパイル使用メモリ 109,192 KB
実行使用メモリ 189,088 KB
最終ジャッジ日時 2023-09-10 21:33:57
合計ジャッジ時間 10,463 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,748 KB
testcase_01 AC 56 ms
20,856 KB
testcase_02 AC 58 ms
20,872 KB
testcase_03 AC 61 ms
23,096 KB
testcase_04 AC 57 ms
19,048 KB
testcase_05 AC 58 ms
21,628 KB
testcase_06 AC 57 ms
20,868 KB
testcase_07 AC 56 ms
20,736 KB
testcase_08 AC 168 ms
23,296 KB
testcase_09 AC 169 ms
25,280 KB
testcase_10 AC 57 ms
20,828 KB
testcase_11 AC 57 ms
20,936 KB
testcase_12 AC 57 ms
22,928 KB
testcase_13 AC 176 ms
23,664 KB
testcase_14 AC 294 ms
189,088 KB
testcase_15 AC 157 ms
25,372 KB
testcase_16 AC 170 ms
23,244 KB
testcase_17 AC 256 ms
108,788 KB
testcase_18 AC 121 ms
52,928 KB
testcase_19 AC 175 ms
62,844 KB
testcase_20 AC 344 ms
167,100 KB
testcase_21 AC 341 ms
165,880 KB
testcase_22 AC 342 ms
167,316 KB
testcase_23 AC 339 ms
167,164 KB
testcase_24 AC 179 ms
23,440 KB
testcase_25 AC 179 ms
25,264 KB
testcase_26 AC 203 ms
23,400 KB
testcase_27 AC 207 ms
25,296 KB
testcase_28 AC 204 ms
25,296 KB
testcase_29 AC 201 ms
23,412 KB
testcase_30 AC 57 ms
22,788 KB
testcase_31 AC 58 ms
22,972 KB
testcase_32 AC 57 ms
22,956 KB
testcase_33 AC 58 ms
20,932 KB
testcase_34 AC 57 ms
21,056 KB
testcase_35 AC 57 ms
20,876 KB
testcase_36 AC 57 ms
23,136 KB
testcase_37 AC 57 ms
21,016 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		memo = new bool[H,W,MaxSize];
		
		memo[Si,Sj,A] = true;
		dfs(Si,Sj,A);
		
		Console.WriteLine(memo[Gi,Gj,B]?"Yes":"No");
		
	}
	
	static int MaxSize = 1200;
	bool[,,] memo;
	static int[] dx = {1,0,-1,0};
	static int[] dy = {0,-1,0,1};
	
	void dfs(int y, int x, int sz){
		for(int t=0;t<4;t++){
			int ny = y + dy[t];
			int nx = x + dx[t];
			if(!InRange(ny,nx,H,W)) continue;
			
			int nsz = sz;
			if(M[ny][nx] == '.') nsz-- ;
			if(M[ny][nx] == '*') nsz++ ;
			if(nsz <=0 || nsz >= MaxSize)continue;
			
			if(!memo[ny,nx,nsz]){
				memo[ny,nx,nsz] = true;
				dfs(ny,nx,nsz);
			}
		}
	}
	
	static bool InRange(int r,int c,int rmax,int cmax){
		return r >= 0 && r < rmax && c >= 0 && c < cmax;
	}
	
	static int H,W;
	static String[] M;
	
	int A,Si,Sj;
	int B,Gi,Gj;
	

	public Sol(){
		var d = ria();
		H = d[0]; W = d[1];
		d = ria();
		A = d[0]; Si = d[1]; Sj = d[2];
		d = ria();
		B = d[0]; Gi = d[1]; Gj = d[2];
		
		M = new String[H];
		for(int i=0;i<H;i++){
			M[i] = rs();
		}
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0