Submission #34533


Source Code Expand

Copy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Amidakuji
{
    class Program
    {
        static int[,] horizon;
        static int vCount, vLength;

        static void Main(string[] args)
        {
            var split = Console.ReadLine().Split(' ');
            vCount = int.Parse(split[0]);
            vLength = int.Parse(split[1]);

            if (vCount == 1)
            {
                Console.WriteLine("1");
                return;
            }

            horizon = new int[vCount - 1, vLength];

            int line = vLength;
            while (line-- > 0)
            {
                var input = Console.ReadLine().Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                var h = input.Select(s =>
                {
                    if (s == " ") return 0;
                    else if (s == "-") return 1;
                    else return -1;
                });
                int i = 0;
                int count = vLength - 1 - line;
                foreach (var hh in h)
                {
                    horizon[i, count] = hh;
                    i++;
                }
            }

            int nowPosition = Console.ReadLine().IndexOf('o') / 2;
            for (int i = vLength - 1; i >= 0; i--)
            {
                if (GetHorizonBarState(nowPosition, i) == 1)
                {
                    nowPosition++;
                }
                else if (GetHorizonBarState(nowPosition - 1, i) == 1)
                {
                    nowPosition--;
                }
            }
            nowPosition++;

            Console.WriteLine(nowPosition);
        }

        private static int GetHorizonBarState(int x, int y)
        {
            if (IsOutOfRange(x, y)) return -1;
            return horizon[x, y];
        }

        private static bool IsOutOfRange(int x, int y)
        {
            return horizon == null || x < 0 || x >= vCount - 1 || y < 0 || y >= vLength;
        }
    }
}

Submission Info

Submission Time
Task B - あみだくじ
User jag5X
Language C# (Mono 2.10.8.1)
Score 100
Code Size 2108 Byte
Status AC
Exec Time 156 ms
Memory 8668 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 34
Set Name Test Cases
All 00_min.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_maxrnd_00.txt, 02_maxrnd_01.txt, 02_maxrnd_02.txt, 02_maxrnd_03.txt, 02_maxrnd_04.txt, 03_empty_00.txt, 03_empty_01.txt, 03_empty_02.txt
Case Name Status Exec Time Memory
00_min.txt AC 142 ms 8200 KB
00_sample_01.txt AC 149 ms 8612 KB
00_sample_02.txt AC 148 ms 8612 KB
00_sample_03.txt AC 139 ms 8252 KB
00_sample_04.txt AC 149 ms 8668 KB
00_sample_05.txt AC 149 ms 8604 KB
01_rnd_00.txt AC 147 ms 8580 KB
01_rnd_01.txt AC 146 ms 8604 KB
01_rnd_02.txt AC 147 ms 8624 KB
01_rnd_03.txt AC 148 ms 8640 KB
01_rnd_04.txt AC 148 ms 8616 KB
01_rnd_05.txt AC 151 ms 8608 KB
01_rnd_06.txt AC 152 ms 8616 KB
01_rnd_07.txt AC 150 ms 8596 KB
01_rnd_08.txt AC 147 ms 8616 KB
01_rnd_09.txt AC 149 ms 8608 KB
01_rnd_10.txt AC 147 ms 8616 KB
01_rnd_11.txt AC 147 ms 8612 KB
01_rnd_12.txt AC 148 ms 8620 KB
01_rnd_13.txt AC 148 ms 8616 KB
01_rnd_14.txt AC 148 ms 8620 KB
01_rnd_15.txt AC 142 ms 8292 KB
01_rnd_16.txt AC 137 ms 8248 KB
01_rnd_17.txt AC 156 ms 8612 KB
01_rnd_18.txt AC 139 ms 8252 KB
01_rnd_19.txt AC 149 ms 8576 KB
02_maxrnd_00.txt AC 150 ms 8620 KB
02_maxrnd_01.txt AC 147 ms 8624 KB
02_maxrnd_02.txt AC 146 ms 8616 KB
02_maxrnd_03.txt AC 149 ms 8624 KB
02_maxrnd_04.txt AC 152 ms 8580 KB
03_empty_00.txt AC 144 ms 8616 KB
03_empty_01.txt AC 147 ms 8616 KB
03_empty_02.txt AC 155 ms 8616 KB