Submission #171729


Source Code Expand

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

class Program
{
    void Solve()
    {
        int N = reader.Int();
        int[] A = reader.IntArray();
        int maxVal = A.Max();
        if (maxVal > 2000) { throw new ArgumentException(); }

        int[,] dp = new int[N, maxVal + 1];
        dp[0, A[0]] = 1;

        for (int i = 1; i < N; i++)
        {
            int sum = 0;
            for (int x = 0; x <= maxVal; x++)
            {
                Add(ref sum, dp[i - 1, x]);
                if (A[i] == x || A[i] == -1)
                    Add(ref dp[i, x], sum);
            }
        }

        int ans = 0;
        for (int i = 0; i <= maxVal; i++) Add(ref ans, dp[N - 1, i]);

        Console.WriteLine(ans);
        Console.ReadLine();
    }

    static readonly int Mod = (int)1e9 + 7;
    void Add(ref int a, int b)
    {
        a += b;
        if (a >= Mod) a -= Mod;
    }



    static void Main() { new Program().Solve(); }
    static Reader reader = new Reader(Console.In);

    class Reader
    {
        private readonly TextReader reader;
        private readonly char[] separator = new char[] { ' ' };
        private string[] s = new string[0];
        private int i;
        public Reader(TextReader r) { reader = r; }
        public bool HasNext() { return Enqueue(); }
        public string String() { return Dequeue(); }
        public int Int() { return int.Parse(Dequeue()); }
        public long Long() { return long.Parse(Dequeue()); }
        public double Double() { return double.Parse(Dequeue()); }
        public int[] IntArray() { return Array.ConvertAll(Line().Split(), int.Parse); }
        public int[][] IntGrid(int H) { return Enumerable.Range(0, H).Select(i => IntArray()).ToArray(); }
        public string[] StringArray(int N) { return Enumerable.Range(0, N).Select(i => Line()).ToArray(); }
        public string Line() { return reader.ReadLine().Trim(); }
        private bool Enqueue()
        {
            if (i < s.Length) return true;
            string line = reader.ReadLine();
            if (string.IsNullOrEmpty(line)) return false;
            s = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return true;
        }
        private string Dequeue() { Enqueue(); return s[i++]; }
    }
}

Submission Info

Submission Time
Task C - タコヤ木
User eitaho
Language C# (Mono 2.10.8.1)
Score 80
Code Size 2435 Byte
Status RE
Exec Time 298 ms
Memory 24440 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 50 / 50 30 / 30 0 / 20
Status
AC × 2
RE × 1
AC × 14
AC × 26
AC × 24
RE × 12
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt
Subtask2 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Subtask3 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt
Case Name Status Exec Time Memory
sample_01.txt AC 150 ms 8568 KB
sample_02.txt AC 151 ms 8568 KB
sample_03.txt RE 151 ms 8520 KB
subtask1_01.txt AC 150 ms 8564 KB
subtask1_02.txt AC 150 ms 8560 KB
subtask1_03.txt AC 150 ms 8560 KB
subtask1_04.txt AC 154 ms 8572 KB
subtask1_05.txt AC 151 ms 8700 KB
subtask1_06.txt AC 185 ms 8704 KB
subtask1_07.txt AC 162 ms 8700 KB
subtask1_08.txt AC 157 ms 8692 KB
subtask1_09.txt AC 161 ms 8692 KB
subtask1_10.txt AC 160 ms 8688 KB
subtask1_11.txt AC 161 ms 8624 KB
subtask1_12.txt AC 148 ms 8696 KB
subtask2_01.txt AC 150 ms 8564 KB
subtask2_02.txt AC 147 ms 8552 KB
subtask2_03.txt AC 154 ms 8688 KB
subtask2_04.txt AC 161 ms 9708 KB
subtask2_05.txt AC 157 ms 9972 KB
subtask2_06.txt AC 177 ms 11120 KB
subtask2_07.txt AC 298 ms 24308 KB
subtask2_08.txt AC 228 ms 24404 KB
subtask2_09.txt AC 224 ms 19316 KB
subtask2_10.txt AC 267 ms 24184 KB
subtask2_11.txt AC 233 ms 24324 KB
subtask2_12.txt AC 240 ms 24440 KB
subtask3_01.txt RE 152 ms 8440 KB
subtask3_02.txt RE 153 ms 8356 KB
subtask3_03.txt RE 155 ms 8448 KB
subtask3_04.txt RE 156 ms 8564 KB
subtask3_05.txt RE 154 ms 8436 KB
subtask3_06.txt RE 153 ms 8560 KB
subtask3_07.txt RE 152 ms 8568 KB
subtask3_08.txt RE 155 ms 8684 KB
subtask3_09.txt RE 152 ms 8552 KB
subtask3_10.txt RE 156 ms 8696 KB
subtask3_11.txt RE 151 ms 8560 KB
subtask3_12.txt RE 158 ms 8636 KB