結果

問題 No.323 yuki国
ユーザー kuuso1
提出日時 2015-12-16 00:48:56
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 485 ms / 5,000 ms
コード長 2,129 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 108,032 KB
実行使用メモリ 30,336 KB
最終ジャッジ日時 2024-06-28 12:18:51
合計ジャッジ時間 9,229 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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(){
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;
Queue<int> Q=new Queue<int>();
Q.Enqueue(enc(Si,Sj,A));
while(Q.Count>0){
var p=Q.Dequeue();
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]){
M[nvol][ny][nx]=true;
Q.Enqueue(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));}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0