Submission #6964704


Source Code Expand

using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var command = Console.ReadLine().Split('T').ToArray();
            var xmovegen= command.Where((value,index)=>index%2==0).Select(value=>value.Length);
            var ymove= command.Where((value,index)=>index%2==1).Select(value=>value.Length).ToArray();


            int x, y;
            Read2Ints(out x, out y);
            x -= xmovegen.First();
            var xmove=xmovegen.Skip(1).ToArray();
            var xsm = xmove.Sum();

            var ysm = ymove.Sum();
           var dpx= Enumerable.Range(1, xmove.Length+1).Select(xx => new bool[xmove.Sum() + 2]).ToArray();
            dpx[0][0] = true;
            for(int i = 0; i < xmove.Length; i++) {
                for(int j = 0; j < xmove.Sum(); j++)
                {
                    if (xmove[i] + j < xsm + 2)
                    {
                        dpx[i + 1][xmove[i] + j] |= dpx[i][j];
                    }
                    dpx[i + 1][Abs(xmove[i] - j)] |= dpx[i][j];
                }
            }
       
            
            if (dpx.Last()[Abs(x)]|xsm==Abs(x))
            {
           var dpy= Enumerable.Range(1, ymove.Length+1).Select(xx => new bool[ymove.Sum() + 2]).ToArray();
            dpy[0][0] = true;
            for(int i = 0; i < ymove.Length; i++) {
                for(int j = 0; j < ymove.Sum(); j++)
                {
                     if (ymove[i] + j < ysm + 2)
                    {
                        dpy[i + 1][ymove[i] + j] |= dpy[i][j];
                    }
                    dpx[i + 1][Abs(ymove[i] - j)] |= dpy[i][j];
                }
            }


            if (dpy.Last()[Abs(y)]|ysm==y)
                {
                    Write("Yes");
                }
            else
            {
                Write("No");
            }


            }
            else
            {
                Write("No");
            }




        }

        private static void Read2Ints(out int a, out int b)
        {
            var temp = ReadInts();
            a = temp[0];
            b = temp[1];
        }
        private static void Read3Ints(out int a, out int b, out int c)
        {
            var temp = ReadInts();
            a = temp[0];
            b = temp[1];
            c = temp[2];
        }

        private static void Write(IEnumerable<string> target, string sep = " ") { Console.WriteLine(string.Join(sep, target)); }
        private static void Write(IEnumerable<double> target, string sep = " ") { Console.WriteLine(string.Join(sep, target)); }
        private static void Write(IEnumerable<long> target, string sep = " ") { Console.WriteLine(string.Join(sep, target)); }
        private static void Writeints(IEnumerable<int> target, string sep = " ") { Console.WriteLine(string.Join(sep, target)); }
        private static void Write<T>(T str) { Console.WriteLine(str); }
        private static string[] ReadStrings() { return Console.ReadLine().Split(' '); }
        private static int ReadInt() { return int.Parse(Console.ReadLine()); }
        private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        private static int[] ReadInts() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        private static double[] ReadDoubles() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }

    }

}

Submission Info

Submission Time
Task D - FT Robot
User afnafn
Language C# (Mono 4.6.2.0)
Score 0
Code Size 3696 Byte
Status RE
Exec Time 2109 ms
Memory 28380 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 6
AC × 11
TLE × 32
RE × 13
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt
Case Name Status Exec Time Memory
0_00.txt AC 30 ms 9556 KB
0_01.txt AC 29 ms 11604 KB
0_02.txt AC 30 ms 11604 KB
0_03.txt AC 30 ms 11604 KB
0_04.txt AC 30 ms 11604 KB
0_05.txt AC 30 ms 11604 KB
1_00.txt AC 30 ms 9488 KB
1_01.txt RE 28 ms 9056 KB
1_02.txt RE 29 ms 9184 KB
1_03.txt RE 29 ms 9184 KB
1_04.txt AC 31 ms 11504 KB
1_05.txt AC 30 ms 11504 KB
1_06.txt TLE 2108 ms 17888 KB
1_07.txt TLE 2108 ms 21984 KB
1_08.txt TLE 2108 ms 26460 KB
1_09.txt TLE 2109 ms 26460 KB
1_10.txt RE 299 ms 19676 KB
1_11.txt RE 206 ms 11360 KB
1_12.txt TLE 2108 ms 20832 KB
1_13.txt TLE 2108 ms 18912 KB
1_14.txt TLE 2108 ms 24284 KB
1_15.txt TLE 2108 ms 28380 KB
1_16.txt RE 186 ms 26328 KB
1_17.txt RE 185 ms 26328 KB
1_18.txt TLE 2108 ms 19808 KB
1_19.txt TLE 2108 ms 18016 KB
1_20.txt TLE 2108 ms 24032 KB
1_21.txt TLE 2108 ms 19936 KB
1_22.txt TLE 2108 ms 24032 KB
1_23.txt TLE 2108 ms 22112 KB
1_24.txt TLE 2108 ms 20192 KB
1_25.txt TLE 2108 ms 21984 KB
1_26.txt AC 782 ms 11744 KB
1_27.txt RE 422 ms 11488 KB
1_28.txt TLE 2108 ms 19932 KB
1_29.txt TLE 2108 ms 21984 KB
1_30.txt TLE 2108 ms 21600 KB
1_31.txt TLE 2108 ms 21344 KB
1_32.txt TLE 2108 ms 15456 KB
1_33.txt TLE 2108 ms 17376 KB
1_34.txt TLE 2108 ms 16472 KB
1_35.txt TLE 2108 ms 16352 KB
1_36.txt RE 768 ms 16212 KB
1_37.txt RE 1133 ms 16336 KB
1_38.txt RE 392 ms 14292 KB
1_39.txt RE 265 ms 16088 KB
1_40.txt RE 119 ms 15964 KB
1_41.txt AC 93 ms 13836 KB
1_42.txt TLE 2108 ms 20956 KB
1_43.txt TLE 2108 ms 18908 KB
1_44.txt TLE 2108 ms 18908 KB
1_45.txt TLE 2108 ms 23004 KB
1_46.txt TLE 2108 ms 19808 KB
1_47.txt TLE 2108 ms 17888 KB
1_48.txt TLE 2108 ms 21984 KB
1_49.txt TLE 2108 ms 18016 KB