AtCoder Typical Contest 001

Submission #420841

Source codeソースコード

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

namespace AtCoderTypicalContest001
{
    class Program
    {
        static int[] dy = { 0, 1, 0, -1 };
        static int[] dx = { 1, 0, -1, 0 };
        static void A()
        {
            string[] one = Console.ReadLine().Split(' ');
            int H = int.Parse(one[0]);
            int W = int.Parse(one[1]);
            string[] map = new string[H];
            bool[,] b = new bool[H, W];
            int startx = 0;
            int starty = 0;
            int goalx = 0;
            int goaly = 0;
            for(int i = 0;i<H;i++)
            {
                map[i] = Console.ReadLine();
                for(int j = 0;j<W;j++)
                {
                    if(map[i][j] == 's')
                    {
                        startx = j;
                        starty = i;
                    }

                    if(map[i][j] == 'g')
                    {
                        goalx = j;
                        goaly = i;
                    }
                }
            }

            if(A_Dfs(startx, starty, goalx, goaly, b, map,W,H))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }

        static bool A_Dfs(int nowX,int nowY,int endX,int endY,bool[,] b,string[] map,int W,int H)
        {
            if(map[nowY][nowX] == 'g')return true;
            bool ans = false;
            for (int i = 0; i < 4; i++)
            {
                int nextx = nowX + dx[i];
                int nexty = nowY + dy[i];
                if (nextx < 0 || nextx >= W || nexty < 0 || nexty >= H) continue;
                if (b[nexty, nextx]) continue;
                if (map[nexty][nextx] == '#') continue;
                b[nexty, nextx] = true;
                ans = ans || A_Dfs(nextx, nexty, endX, endY, b, map, W, H);
            }


            return ans;
        }
        static void B()
        {

        }
        static void Main(string[] args)
        {
            A();
            //B();
        }
    }
}

Submission

Task問題 A - 深さ優先探索
User nameユーザ名 tookunn
Created time投稿日時
Language言語 C# (Mono 3.2.1.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 2264 Byte
File nameファイル名
Exec time実行時間 178 ms
Memory usageメモリ使用量 35356 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,00_sample_04.txt,00_sample_05.txt
All 100 / 100 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_min_01.txt AC 162 ms 8816 KB
00_min_02.txt AC 108 ms 8840 KB
00_min_03.txt AC 106 ms 8844 KB
00_min_04.txt AC 109 ms 8852 KB
00_min_05.txt AC 105 ms 8840 KB
00_min_06.txt AC 106 ms 8844 KB
00_min_07.txt AC 107 ms 8844 KB
00_min_08.txt AC 112 ms 8840 KB
00_sample_01.txt AC 118 ms 8844 KB
00_sample_02.txt AC 106 ms 8844 KB
00_sample_03.txt AC 106 ms 8844 KB
00_sample_04.txt AC 107 ms 8844 KB
00_sample_05.txt AC 111 ms 8840 KB
01_rnd_00.txt AC 119 ms 9368 KB
01_rnd_01.txt AC 136 ms 15372 KB
01_rnd_02.txt AC 135 ms 14728 KB
01_rnd_03.txt AC 150 ms 24888 KB
01_rnd_04.txt AC 178 ms 30180 KB
01_rnd_05.txt AC 120 ms 9356 KB
01_rnd_06.txt AC 140 ms 15500 KB
01_rnd_07.txt AC 124 ms 11656 KB
01_rnd_08.txt AC 112 ms 9356 KB
01_rnd_09.txt AC 115 ms 9356 KB
01_rnd_10.txt AC 129 ms 10508 KB
01_rnd_11.txt AC 116 ms 9352 KB
01_rnd_12.txt AC 128 ms 13964 KB
01_rnd_13.txt AC 153 ms 22020 KB
01_rnd_14.txt AC 117 ms 9352 KB
01_rnd_15.txt AC 133 ms 13084 KB
01_rnd_16.txt AC 115 ms 9352 KB
01_rnd_17.txt AC 130 ms 12044 KB
01_rnd_18.txt AC 114 ms 9356 KB
01_rnd_19.txt AC 176 ms 35356 KB
02_rndhard_00.txt AC 125 ms 9356 KB
02_rndhard_01.txt AC 122 ms 9356 KB
02_rndhard_02.txt AC 118 ms 9612 KB
02_rndhard_03.txt AC 116 ms 9612 KB
02_rndhard_04.txt AC 114 ms 9356 KB
02_rndhard_05.txt AC 117 ms 9320 KB
02_rndhard_06.txt AC 115 ms 9388 KB
02_rndhard_07.txt AC 118 ms 9356 KB
02_rndhard_08.txt AC 120 ms 9364 KB
02_rndhard_09.txt AC 117 ms 9480 KB
02_rndhard_10.txt AC 117 ms 9364 KB
02_rndhard_11.txt AC 115 ms 9364 KB
02_rndhard_12.txt AC 115 ms 9356 KB
02_rndhard_13.txt AC 118 ms 9352 KB
02_rndhard_14.txt AC 120 ms 9480 KB
02_rndhard_15.txt AC 120 ms 9468 KB
02_rndhard_16.txt AC 115 ms 9356 KB
02_rndhard_17.txt AC 113 ms 9356 KB
02_rndhard_18.txt AC 113 ms 9352 KB
02_rndhard_19.txt AC 114 ms 9356 KB
02_rndhard_20.txt AC 116 ms 9356 KB
02_rndhard_21.txt AC 117 ms 9356 KB
02_rndhard_22.txt AC 130 ms 9484 KB
02_rndhard_23.txt AC 121 ms 9432 KB
02_rndhard_24.txt AC 116 ms 9352 KB
02_rndhard_25.txt AC 115 ms 9352 KB
02_rndhard_26.txt AC 115 ms 9352 KB
02_rndhard_27.txt AC 116 ms 9352 KB
02_rndhard_28.txt AC 115 ms 9336 KB
02_rndhard_29.txt AC 116 ms 9356 KB
02_rndhard_30.txt AC 117 ms 9352 KB
02_rndhard_31.txt AC 116 ms 9368 KB
02_rndhard_32.txt AC 114 ms 9484 KB
02_rndhard_33.txt AC 114 ms 9356 KB
02_rndhard_34.txt AC 119 ms 9364 KB
02_rndhard_35.txt AC 115 ms 9356 KB
02_rndhard_36.txt AC 119 ms 9356 KB
02_rndhard_37.txt AC 116 ms 9360 KB
02_rndhard_38.txt AC 127 ms 9340 KB
02_rndhard_39.txt AC 116 ms 9348 KB
03_rndhardsmall_00.txt AC 107 ms 8852 KB
03_rndhardsmall_01.txt AC 106 ms 8852 KB
03_rndhardsmall_02.txt AC 106 ms 8844 KB
03_rndhardsmall_03.txt AC 107 ms 8828 KB
03_rndhardsmall_04.txt AC 107 ms 8844 KB
03_rndhardsmall_05.txt AC 107 ms 8844 KB
03_rndhardsmall_06.txt AC 105 ms 8840 KB
03_rndhardsmall_07.txt AC 105 ms 8844 KB
03_rndhardsmall_08.txt AC 106 ms 8852 KB
03_rndhardsmall_09.txt AC 112 ms 8824 KB