Submission #1770955


Source Code Expand

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

namespace ProgrammingContest
{
    class MainClass : IDisposable
    {
        Scanner sc;
        Writer wr;
        string backPath = "..";
        char dirSep = System.IO.Path.DirectorySeparatorChar;
        string inFilePath = null;
        string outFilePath = null;
        public MainClass()
        {
            this.inFilePath = this.backPath
                            + this.dirSep
                            + this.backPath
                            + this.dirSep
                            + "in.txt";
            this.outFilePath = this.backPath
                             + this.dirSep
                             + this.backPath
                             + this.dirSep
                             + "out.txt";
        }
        static void Main(string[] args)
        {
            using (var mainClass = new MainClass())
            {
                //mainClass.MakeTestCase();
                mainClass.Solve();
            }
        }

        public void Dispose()
        {
            if (this.sc != null)
            {
                this.sc.Dispose();
                this.sc = null;
            }
            if (this.wr != null)
            {
                this.wr.Dispose();
                this.wr = null;
            }
        }

        void MakeTestCase()
        {
            Random rand = new Random();
            this.wr = new Writer(inFilePath);


        }

        void Solve()
        {
            this.wr = new Writer(this.isReactive);
            //this.wr = new Writer(this.outFilePath);
#if DEBUG
            if (!this.isReactive)
                this.sc = new Scanner(this.inFilePath);
            else
                this.sc = new Scanner();
#else
            this.sc = new Scanner();
#endif

            const long MOD = (long)1e9 + 7;
            int N = sc.NextInt;
            var S = sc.Next;
            var T = new string[N].Select(e => sc.Next).ToArray();
            long[] dp = new long[S.Length + 1];
            dp[0] = 1;
            for (int i = 0; i < S.Length; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    bool ok = true;
                    for (int k = 0; k < T[j].Length; k++)
                    {
                        ok &= (i + k < S.Length && S[i + k] == T[j][k]);
                    }
                    if (ok)
                    {
                        dp[i + T[j].Length] += dp[i];
                        dp[i + T[j].Length] %= MOD;
                    }
                }
            }
            wr.WriteLine(dp[S.Length]);
        }

        bool isReactive = false; // TODO: reactive check !!
    }

    class Writer : IDisposable
    {
        private System.IO.TextWriter writer;
        private StringBuilder sb;
        private bool isReactive;
        public Writer(string path) : this(new System.IO.StreamWriter(path))
        {
        }
        public Writer(bool isReactive) : this(null, isReactive)
        {
        }
        public Writer(System.IO.TextWriter writer = null, bool isReactive = false)
        {
            this.writer = (writer ?? Console.Out);
            this.isReactive = isReactive;
            if (!this.isReactive)
                this.sb = new StringBuilder();
        }
        public void Dispose()
        {
            if (!this.isReactive)
                this.writer.Write(sb.ToString());
            if (!this.writer.Equals(Console.Out))
                this.writer.Dispose();
        }
        public void Write(object val)
        {
            if (this.isReactive)
            {
                this.writer.Write(val.ToString());
                this.writer.Flush();
            }
            else
                this.sb.Append(val.ToString());
        }
        public void Write(string format, params object[] vals)
        {
            if (this.isReactive)
            {
                this.writer.Write(format, vals);
                this.writer.Flush();
            }
            else
                this.sb.AppendFormat(format, vals);
        }
        public void WriteLine(object val)
        {
            this.Write(val.ToString() + System.Environment.NewLine);
        }
        public void WriteLine(string format, params object[] vals)
        {
            this.Write(format + System.Environment.NewLine, vals);
        }
    }

    class Scanner : IDisposable
    {
        private Queue<string> buffer;
        private char[] sep;
        private System.IO.TextReader reader;
        public Scanner(string path) : this(new System.IO.StreamReader(path))
        {
        }
        public Scanner(System.IO.TextReader reader = null)
        {
            this.buffer = new Queue<string>();
            this.sep = new char[] { ' ' };
            this.reader = (reader ?? Console.In);
        }
        private void CheckBuffer()
        {
            if (this.buffer.Count == 0)
            {
                string str = string.Empty;
                while (string.IsNullOrEmpty(str))
                    str = this.reader.ReadLine();

                str.Split(this.sep).ToList()
                    .ForEach(el => this.buffer.Enqueue(el));
            }
        }

        public void Dispose()
        {
            if (!this.reader.Equals(Console.In))
                this.reader.Dispose();
        }

        public string Next
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Dequeue();
            }
        }

        public int NextInt
        {
            get
            {
                return int.Parse(this.Next);
            }
        }
        public double NextDouble
        {
            get
            {
                return double.Parse(this.Next);
            }
        }

        public long NextLong
        {
            get
            {
                return long.Parse(this.Next);
            }
        }

        public bool IsEnd
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Count == 0;
            }
        }
    }
}

Submission Info

Submission Time
Task B - エターナルスタティックファイナル
User sekiya9311
Language C# (Mono 4.6.2.0)
Score 60
Code Size 6424 Byte
Status AC
Exec Time 64 ms
Memory 13524 KB

Judge Result

Set Name All
Score / Max Score 60 / 60
Status
AC × 108
Set Name Test Cases
All 00_sample00.txt, 00_sample01.txt, 00_sample02.txt, 00_sample03.txt, 00_sample04.txt, 01_random00.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt, 01_random08.txt, 01_random09.txt, 01_random10.txt, 01_random11.txt, 01_random12.txt, 01_random13.txt, 01_random14.txt, 01_random15.txt, 01_random16.txt, 01_random17.txt, 01_random18.txt, 01_random19.txt, 01_random20.txt, 01_random21.txt, 01_random22.txt, 01_random23.txt, 01_random24.txt, 01_random25.txt, 01_random26.txt, 01_random27.txt, 01_random28.txt, 01_random29.txt, 01_random30.txt, 01_random31.txt, 01_random32.txt, 01_random33.txt, 01_random34.txt, 01_random35.txt, 01_random36.txt, 01_random37.txt, 01_random38.txt, 01_random39.txt, 01_random40.txt, 01_random41.txt, 01_random42.txt, 01_random43.txt, 01_random44.txt, 01_random45.txt, 01_random46.txt, 01_random47.txt, 01_random48.txt, 01_random49.txt, 01_random50.txt, 01_random51.txt, 01_random52.txt, 01_random53.txt, 01_random54.txt, 01_random55.txt, 01_random56.txt, 01_random57.txt, 01_random58.txt, 01_random59.txt, 01_random61.txt, 01_random62.txt, 01_random63.txt, 01_random64.txt, 01_random65.txt, 01_random66.txt, 01_random67.txt, 01_random68.txt, 01_random69.txt, 01_random70.txt, 01_random71.txt, 01_random72.txt, 01_random73.txt, 01_random74.txt, 01_random75.txt, 01_random76.txt, 01_random77.txt, 01_random78.txt, 01_random79.txt, 01_random80.txt, 01_random81.txt, 01_random82.txt, 01_random83.txt, 01_random84.txt, 01_random85.txt, 01_random86.txt, 01_random87.txt, 01_random88.txt, 01_random89.txt, 01_random90.txt, 01_random91.txt, 01_random92.txt, 01_random93.txt, 01_random94.txt, 01_random95.txt, 01_random96.txt, 01_random97.txt, 01_random98.txt, 01_random99.txt, 02_manual00.txt, 02_manual01.txt, 02_manual02.txt, 02_manual03.txt
Case Name Status Exec Time Memory
00_sample00.txt AC 29 ms 11348 KB
00_sample01.txt AC 30 ms 13524 KB
00_sample02.txt AC 29 ms 9428 KB
00_sample03.txt AC 29 ms 9428 KB
00_sample04.txt AC 30 ms 11476 KB
01_random00.txt AC 51 ms 11476 KB
01_random01.txt AC 50 ms 11348 KB
01_random02.txt AC 29 ms 11476 KB
01_random03.txt AC 30 ms 11476 KB
01_random04.txt AC 32 ms 9428 KB
01_random05.txt AC 63 ms 11476 KB
01_random06.txt AC 42 ms 13524 KB
01_random07.txt AC 30 ms 11476 KB
01_random08.txt AC 30 ms 11476 KB
01_random09.txt AC 31 ms 11476 KB
01_random10.txt AC 32 ms 9428 KB
01_random11.txt AC 35 ms 11348 KB
01_random12.txt AC 39 ms 11348 KB
01_random13.txt AC 30 ms 11348 KB
01_random14.txt AC 40 ms 11348 KB
01_random15.txt AC 30 ms 11476 KB
01_random16.txt AC 33 ms 13396 KB
01_random17.txt AC 39 ms 11476 KB
01_random18.txt AC 30 ms 11476 KB
01_random19.txt AC 37 ms 9300 KB
01_random20.txt AC 40 ms 11476 KB
01_random21.txt AC 53 ms 11476 KB
01_random22.txt AC 30 ms 11476 KB
01_random23.txt AC 30 ms 13396 KB
01_random24.txt AC 32 ms 11476 KB
01_random25.txt AC 29 ms 11348 KB
01_random26.txt AC 34 ms 11476 KB
01_random27.txt AC 49 ms 13396 KB
01_random28.txt AC 31 ms 13524 KB
01_random29.txt AC 29 ms 9428 KB
01_random30.txt AC 31 ms 13524 KB
01_random31.txt AC 42 ms 11476 KB
01_random32.txt AC 33 ms 11348 KB
01_random33.txt AC 36 ms 9428 KB
01_random34.txt AC 55 ms 13396 KB
01_random35.txt AC 41 ms 9428 KB
01_random36.txt AC 39 ms 11476 KB
01_random37.txt AC 31 ms 11348 KB
01_random38.txt AC 64 ms 11476 KB
01_random39.txt AC 62 ms 11476 KB
01_random40.txt AC 36 ms 9428 KB
01_random41.txt AC 42 ms 13524 KB
01_random42.txt AC 49 ms 11476 KB
01_random43.txt AC 63 ms 11476 KB
01_random44.txt AC 36 ms 11476 KB
01_random45.txt AC 37 ms 11348 KB
01_random46.txt AC 57 ms 11476 KB
01_random47.txt AC 41 ms 11476 KB
01_random48.txt AC 39 ms 9428 KB
01_random49.txt AC 35 ms 11348 KB
01_random50.txt AC 33 ms 11476 KB
01_random51.txt AC 33 ms 11348 KB
01_random52.txt AC 29 ms 11476 KB
01_random53.txt AC 30 ms 11348 KB
01_random54.txt AC 50 ms 9428 KB
01_random55.txt AC 52 ms 13396 KB
01_random56.txt AC 30 ms 11348 KB
01_random57.txt AC 31 ms 11348 KB
01_random58.txt AC 40 ms 11476 KB
01_random59.txt AC 31 ms 11476 KB
01_random61.txt AC 53 ms 11476 KB
01_random62.txt AC 32 ms 9300 KB
01_random63.txt AC 56 ms 11476 KB
01_random64.txt AC 31 ms 11476 KB
01_random65.txt AC 41 ms 13524 KB
01_random66.txt AC 54 ms 13524 KB
01_random67.txt AC 30 ms 9428 KB
01_random68.txt AC 52 ms 11348 KB
01_random69.txt AC 44 ms 13396 KB
01_random70.txt AC 32 ms 11348 KB
01_random71.txt AC 30 ms 11348 KB
01_random72.txt AC 51 ms 9428 KB
01_random73.txt AC 60 ms 11476 KB
01_random74.txt AC 48 ms 11476 KB
01_random75.txt AC 35 ms 13396 KB
01_random76.txt AC 38 ms 11476 KB
01_random77.txt AC 49 ms 9428 KB
01_random78.txt AC 35 ms 11476 KB
01_random79.txt AC 39 ms 9300 KB
01_random80.txt AC 46 ms 11348 KB
01_random81.txt AC 35 ms 13396 KB
01_random82.txt AC 31 ms 13396 KB
01_random83.txt AC 31 ms 11348 KB
01_random84.txt AC 36 ms 13524 KB
01_random85.txt AC 30 ms 11476 KB
01_random86.txt AC 60 ms 13396 KB
01_random87.txt AC 46 ms 13524 KB
01_random88.txt AC 36 ms 13396 KB
01_random89.txt AC 51 ms 11476 KB
01_random90.txt AC 40 ms 11476 KB
01_random91.txt AC 52 ms 11476 KB
01_random92.txt AC 38 ms 11476 KB
01_random93.txt AC 34 ms 9428 KB
01_random94.txt AC 52 ms 11476 KB
01_random95.txt AC 34 ms 9428 KB
01_random96.txt AC 63 ms 11348 KB
01_random97.txt AC 33 ms 13524 KB
01_random98.txt AC 34 ms 13524 KB
01_random99.txt AC 35 ms 11348 KB
02_manual00.txt AC 50 ms 11460 KB
02_manual01.txt AC 29 ms 9428 KB
02_manual02.txt AC 29 ms 13524 KB
02_manual03.txt AC 29 ms 11476 KB