結果

問題 No.323 yuki国
ユーザー kuuso1kuuso1
提出日時 2015-12-16 00:54:46
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 522 ms / 5,000 ms
コード長 2,213 bytes
コンパイル時間 2,422 ms
コンパイル使用メモリ 108,872 KB
実行使用メモリ 53,904 KB
最終ジャッジ日時 2023-09-10 21:15:53
合計ジャッジ時間 9,885 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
22,648 KB
testcase_01 AC 59 ms
20,728 KB
testcase_02 AC 59 ms
20,708 KB
testcase_03 AC 60 ms
20,768 KB
testcase_04 AC 60 ms
22,700 KB
testcase_05 AC 62 ms
20,596 KB
testcase_06 AC 61 ms
20,696 KB
testcase_07 AC 59 ms
20,780 KB
testcase_08 AC 305 ms
33,616 KB
testcase_09 AC 173 ms
33,468 KB
testcase_10 AC 60 ms
20,668 KB
testcase_11 AC 59 ms
18,632 KB
testcase_12 AC 60 ms
22,716 KB
testcase_13 AC 165 ms
31,400 KB
testcase_14 AC 301 ms
33,492 KB
testcase_15 AC 169 ms
35,536 KB
testcase_16 AC 306 ms
33,496 KB
testcase_17 AC 170 ms
38,856 KB
testcase_18 AC 120 ms
34,436 KB
testcase_19 AC 252 ms
34,796 KB
testcase_20 AC 86 ms
35,960 KB
testcase_21 AC 520 ms
53,264 KB
testcase_22 AC 88 ms
34,436 KB
testcase_23 AC 522 ms
53,904 KB
testcase_24 AC 197 ms
35,464 KB
testcase_25 AC 199 ms
33,384 KB
testcase_26 AC 374 ms
33,420 KB
testcase_27 AC 386 ms
35,608 KB
testcase_28 AC 199 ms
33,508 KB
testcase_29 AC 201 ms
33,400 KB
testcase_30 AC 58 ms
20,732 KB
testcase_31 AC 58 ms
22,696 KB
testcase_32 AC 60 ms
20,728 KB
testcase_33 AC 60 ms
20,768 KB
testcase_34 AC 60 ms
20,764 KB
testcase_35 AC 59 ms
20,792 KB
testcase_36 AC 59 ms
20,832 KB
testcase_37 AC 60 ms
20,668 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(){
		
		int Top=2500;
		
		bool[][][] M=new bool[Top][][];
		for(int t=0;t<Top;t++){
			M[t]=new bool[H][];
			for(int i=0;i<H;i++){
				M[t][i]=new bool[W];
			}
		}
		
		int[] dy=new int[]{0,1,0,-1};
		int[] dx=new int[]{1,0,-1,0};
		M[A][Si][Sj]=true;
		Stack<int> Stk=new Stack<int>();
		Stk.Push(enc(Si,Sj,A));
		while(Stk.Count>0){
			var p=Stk.Pop();
			int x=decC(p);
			int y=decR(p);
			int vol=decV(p);
			for(int t=0;t<4;t++){
				int nx=x+dx[t];
				int ny=y+dy[t];
				if(!InRange(nx,W)||!InRange(ny,H))continue;
				int nvol=vol;
				if(Map[ny][nx]=='*')nvol++;
				if(Map[ny][nx]=='.')nvol--;
				if(!InRange(nvol,Top,1))continue;
				if(!M[nvol][ny][nx]){
					if(ny==Gi && nx==Gj && nvol==B){
						Console.WriteLine("Yes");return;
					}
					M[nvol][ny][nx]=true;
					Stk.Push(enc(ny,nx,nvol));
				}
			}
		}
		
		Console.WriteLine(M[B][Gi][Gj]?"Yes":"No");
		
		
	}
	
	static bool InRange(int t,int ul,int ll=0){
		return (t<ul)&&(t>=ll);
	}
	
	static int decR(int s){
		return s&0xFF;
	}
	static int decC(int s){
		return (s>>8)&0xFF;
	}
	static int decV(int s){
		return s>>16;
	}
	static int enc(int r,int c,int v){
		return r+(c<<8)+(v<<16);
	}
	
	
	
	int H,W;
	int A,Si,Sj;
	int B,Gi,Gj;
	String[] Map;
	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];
		Map=new String[H];
		for(int i=0;i<H;i++)Map[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