結果

問題 No.323 yuki国
ユーザー kuuso1
提出日時 2016-06-12 04:44:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 331 ms / 5,000 ms
コード長 1,805 bytes
コンパイル時間 875 ms
コンパイル使用メモリ 115,684 KB
実行使用メモリ 183,936 KB
最終ジャッジ日時 2024-06-28 12:36:44
合計ジャッジ時間 6,131 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
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