Submission #1513338


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using static CS_Contest.Utils;
using System.IO;
//using static CS_Contest.Library;

namespace CS_Contest {
	using Li = List<int>;
	using LLi = List<List<int>>;
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
			SetOut(sw);
			new Calc().Solve();

			return;
        }

		private class Calc {
			private List<char[]> Box = new List<char[]>();
			Li HW;
			public void Solve() {
				HW = ReadInt(' ');
				Tuple<int, int> idx=new Tuple<int, int>(0,0);
				REP(HW[0], x => {
					Box.Add(ReadLine().Where(k=>k!=32).ToArray());
					if (Box[x].Contains('s')) idx = new Tuple<int, int>(x, Box[x].ToList().IndexOf('s'));
				});
				DFS(idx.Item2, idx.Item1);
				if (enable) Yes();
				else No();
				Out.Flush();
				return;
			}
			private bool enable = false;
			private int[] DirX = new int[] { 0, 1, 0, -1 };
			private int[] DirY = new int[] { 1, 0, -1, 0 };

			private void DFS(int x,int y) {
				if (Box[y][x] == 'g') { enable = true; return; }
				if (enable) return;
				Box[y][x] = '_';
				REP(4, k => {
					int xx = x + DirX[k], yy = y + DirY[k];
					if (xx < 0 || xx > HW[1]-1 || yy < 0 || yy > HW[0]-1) return;
					if (Box[yy][xx] == '_' || Box[yy][xx] == '#') return;
					if (enable) return;
					DFS(xx, yy);
				});
			}
		}
	}


	public static class Utils {
		public static int ModValue = (int)(1e9+7);
		public static long INF = long.MaxValue;
		public static long Mod(long x) => x % ModValue;
		public static long ModPow(long x,long n) { long tmp = 1; while (n != 0) { if (n % 2 == 1) { tmp = Mod(tmp * x); }x = Mod(x * x);n /= 2; }return tmp; }
		public static long DivMod(long x, long y) => Mod(x * ModPow(y, (long)(1e9 + 5)));
        public static void WL(this object obj) => WriteLine(obj);
        public static void WL(this string obj) => WriteLine(obj);
        public static void WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL());
		public static int ReadInt() => int.Parse(ReadLine());
		public static List<int> ReadInt(char s) => ReadLine().Split(s).Where(x=>x!="").Select(int.Parse).ToList();
		public static long ReadLong() => long.Parse(ReadLine());
		public static List<long> ReadLong(char s) => ReadLine().Split(s).Select(long.Parse).ToList();
		public static void ReadMulti(out int x, out int y) {
			var i = ReadInt(' ');
			x = i[0]; y = i[1];

		}
		public static void ReadMulti(out long x, out long y) {
			var i = ReadLong(' ');
			x = i[0];y = i[1];
		}
		public static void ReadMulti(out int x, out int y, out int z) {
			var i = ReadInt(' ');
			x = i[0];y = i[1];z = i[2];
		}
		public static void ReadMulti(out int x, out int y, out int z, out int v) {
			var i = ReadInt(' ');
			x = i[0]; y = i[1]; z = i[2];v = i[3];
		}

		public static long GCD(long m,long n) {
			long tmp;
			while(m%n!=0) {
				tmp = n;
				n = m % n;
				m = tmp;
			}
			return n;
		}
		public static long LCM(long m, long n) => m * (n / GCD(m, n));

		public static void REP(int n,Action<int> act) {
			for (int i = 0; i < n; i++) {
				act(i);
			}
		}
		public static void RREP(int n,Action<int> act) {
			for (int i = n-1; i >=0; i--) {
				act(i);
			}
		}
		public static void REP(long n, Action<int> act) => REP((int)n, act);
		public static void RREP(long n, Action<int> act) => RREP((int)n, act);

		public static void Yes() => "Yes".WL();
		public static void No() => "No".WL();
		public static void YES() => "YES".WL();
		public static void NO() => "NO".WL();


		public static int ManhattanDistance(int x1, int y1, int x2, int y2) => Abs(x2 - x1) + Abs(y2 - y1);




	}
}

Submission Info

Submission Time
Task A - 深さ優先探索
User xztaityozx
Language C# (Mono 4.6.2.0)
Score 0
Code Size 3906 Byte
Status TLE
Exec Time 2108 ms
Memory 36620 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 5
AC × 76
TLE × 7
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt
All 00_min_01.txt, 00_min_02.txt, 00_min_03.txt, 00_min_04.txt, 00_min_05.txt, 00_min_06.txt, 00_min_07.txt, 00_min_08.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_rndhard_00.txt, 02_rndhard_01.txt, 02_rndhard_02.txt, 02_rndhard_03.txt, 02_rndhard_04.txt, 02_rndhard_05.txt, 02_rndhard_06.txt, 02_rndhard_07.txt, 02_rndhard_08.txt, 02_rndhard_09.txt, 02_rndhard_10.txt, 02_rndhard_11.txt, 02_rndhard_12.txt, 02_rndhard_13.txt, 02_rndhard_14.txt, 02_rndhard_15.txt, 02_rndhard_16.txt, 02_rndhard_17.txt, 02_rndhard_18.txt, 02_rndhard_19.txt, 02_rndhard_20.txt, 02_rndhard_21.txt, 02_rndhard_22.txt, 02_rndhard_23.txt, 02_rndhard_24.txt, 02_rndhard_25.txt, 02_rndhard_26.txt, 02_rndhard_27.txt, 02_rndhard_28.txt, 02_rndhard_29.txt, 02_rndhard_30.txt, 02_rndhard_31.txt, 02_rndhard_32.txt, 02_rndhard_33.txt, 02_rndhard_34.txt, 02_rndhard_35.txt, 02_rndhard_36.txt, 02_rndhard_37.txt, 02_rndhard_38.txt, 02_rndhard_39.txt, 03_rndhardsmall_00.txt, 03_rndhardsmall_01.txt, 03_rndhardsmall_02.txt, 03_rndhardsmall_03.txt, 03_rndhardsmall_04.txt, 03_rndhardsmall_05.txt, 03_rndhardsmall_06.txt, 03_rndhardsmall_07.txt, 03_rndhardsmall_08.txt, 03_rndhardsmall_09.txt
Case Name Status Exec Time Memory
00_min_01.txt AC 28 ms 11360 KB
00_min_02.txt AC 28 ms 11360 KB
00_min_03.txt AC 28 ms 11360 KB
00_min_04.txt AC 28 ms 11480 KB
00_min_05.txt AC 28 ms 9312 KB
00_min_06.txt AC 28 ms 9312 KB
00_min_07.txt AC 28 ms 9312 KB
00_min_08.txt AC 28 ms 11360 KB
00_sample_01.txt AC 28 ms 11360 KB
00_sample_02.txt AC 27 ms 9312 KB
00_sample_03.txt AC 28 ms 11360 KB
00_sample_04.txt AC 28 ms 11360 KB
00_sample_05.txt AC 28 ms 11360 KB
01_rnd_00.txt AC 39 ms 15964 KB
01_rnd_01.txt TLE 2108 ms 17856 KB
01_rnd_02.txt TLE 2108 ms 16960 KB
01_rnd_03.txt TLE 2108 ms 20160 KB
01_rnd_04.txt TLE 2108 ms 19904 KB
01_rnd_05.txt AC 40 ms 16084 KB
01_rnd_06.txt TLE 2052 ms 36620 KB
01_rnd_07.txt AC 1598 ms 23868 KB
01_rnd_08.txt AC 39 ms 14040 KB
01_rnd_09.txt AC 39 ms 14036 KB
01_rnd_10.txt AC 480 ms 17380 KB
01_rnd_11.txt AC 39 ms 16084 KB
01_rnd_12.txt AC 42 ms 15448 KB
01_rnd_13.txt TLE 2108 ms 19440 KB
01_rnd_14.txt AC 39 ms 14036 KB
01_rnd_15.txt AC 1000 ms 21344 KB
01_rnd_16.txt AC 43 ms 14040 KB
01_rnd_17.txt AC 850 ms 21276 KB
01_rnd_18.txt AC 40 ms 15964 KB
01_rnd_19.txt TLE 2108 ms 18112 KB
02_rndhard_00.txt AC 39 ms 14040 KB
02_rndhard_01.txt AC 40 ms 18132 KB
02_rndhard_02.txt AC 43 ms 14168 KB
02_rndhard_03.txt AC 43 ms 16216 KB
02_rndhard_04.txt AC 39 ms 16084 KB
02_rndhard_05.txt AC 39 ms 16088 KB
02_rndhard_06.txt AC 39 ms 14036 KB
02_rndhard_07.txt AC 40 ms 18132 KB
02_rndhard_08.txt AC 40 ms 16088 KB
02_rndhard_09.txt AC 40 ms 14040 KB
02_rndhard_10.txt AC 41 ms 18136 KB
02_rndhard_11.txt AC 41 ms 14040 KB
02_rndhard_12.txt AC 40 ms 16088 KB
02_rndhard_13.txt AC 41 ms 18124 KB
02_rndhard_14.txt AC 40 ms 14040 KB
02_rndhard_15.txt AC 41 ms 16204 KB
02_rndhard_16.txt AC 39 ms 14040 KB
02_rndhard_17.txt AC 40 ms 16084 KB
02_rndhard_18.txt AC 40 ms 16084 KB
02_rndhard_19.txt AC 40 ms 18132 KB
02_rndhard_20.txt AC 40 ms 16088 KB
02_rndhard_21.txt AC 40 ms 16088 KB
02_rndhard_22.txt AC 40 ms 18136 KB
02_rndhard_23.txt AC 41 ms 16088 KB
02_rndhard_24.txt AC 40 ms 16084 KB
02_rndhard_25.txt AC 40 ms 16084 KB
02_rndhard_26.txt AC 40 ms 18124 KB
02_rndhard_27.txt AC 40 ms 16088 KB
02_rndhard_28.txt AC 40 ms 16088 KB
02_rndhard_29.txt AC 40 ms 18136 KB
02_rndhard_30.txt AC 39 ms 14036 KB
02_rndhard_31.txt AC 40 ms 16076 KB
02_rndhard_32.txt AC 41 ms 18124 KB
02_rndhard_33.txt AC 40 ms 16088 KB
02_rndhard_34.txt AC 42 ms 18124 KB
02_rndhard_35.txt AC 40 ms 16084 KB
02_rndhard_36.txt AC 40 ms 18132 KB
02_rndhard_37.txt AC 40 ms 16084 KB
02_rndhard_38.txt AC 40 ms 16088 KB
02_rndhard_39.txt AC 39 ms 14040 KB
03_rndhardsmall_00.txt AC 28 ms 11360 KB
03_rndhardsmall_01.txt AC 28 ms 9312 KB
03_rndhardsmall_02.txt AC 28 ms 11360 KB
03_rndhardsmall_03.txt AC 28 ms 11360 KB
03_rndhardsmall_04.txt AC 28 ms 11360 KB
03_rndhardsmall_05.txt AC 28 ms 11360 KB
03_rndhardsmall_06.txt AC 28 ms 11360 KB
03_rndhardsmall_07.txt AC 29 ms 13408 KB
03_rndhardsmall_08.txt AC 28 ms 11360 KB
03_rndhardsmall_09.txt AC 28 ms 9312 KB