結果

問題 No.398 ハーフパイプ(2)
ユーザー りあんりあん
提出日時 2016-07-14 15:18:06
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,527 bytes
コンパイル時間 3,191 ms
コンパイル使用メモリ 100,768 KB
実行使用メモリ 29,880 KB
最終ジャッジ日時 2023-09-09 21:52:39
合計ジャッジ時間 33,547 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
22,768 KB
testcase_01 AC 222 ms
26,876 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 AC 619 ms
24,804 KB
testcase_07 AC 1,278 ms
24,904 KB
testcase_08 AC 220 ms
24,724 KB
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 1,601 ms
25,580 KB
testcase_16 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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

class Program
{
    static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        var s = Console.ReadLine();
        if (s != s.Trim())
        {
            Console.WriteLine("unexpected spase");
            return;
        }
        var x = double.Parse(s) * 4 + 1e-9;
        int sum = (int)x;
        if (x - sum > 1e-7)
        {
            Console.WriteLine("unexpected input");
            return;            
        }
        long ans = 0;
        for (int i = 0; i < 101; i++)
        {
            if (i * 4 > sum) continue;

            for (int j = i; j < 101; j++)
            {
                if (j * 4 < sum) continue;

                int lim = j - i;
                int limsum = sum + j - i * 5;
                var dp = new long[limsum + 1][];
                for (int k = 0; k <= limsum; k++)
                {
                    dp[k] = new long[4];
                }
                dp[0][0] = 1;
                for (int k = 0; k < 6; k++)
                {
                    var next = new long[limsum + 1][];
                    for (int l = 0; l <= limsum; l++)
                    {
                        next[l] = new long[4];
                    }
                    for (int l = 0; l <= limsum; l++)
                    {
                        if (lim == 0)
                        {
                            next[l][3] += dp[l][0] + dp[l][1] + dp[l][2] + dp[l][3];
                        }
                        else
                        {
                            next[l][1] += dp[l][0] + dp[l][1];
                            next[l][3] += dp[l][2] + dp[l][3];
                            if (l >= lim)
                            {
                                next[l][2] += dp[l - lim][0] + dp[l - lim][2];
                                next[l][3] += dp[l - lim][1] + dp[l - lim][3];
                            }
                        }
                        for (int m = 1; m < lim && m <= l; m++)
                        {
                            for (int p = 0; p < 4; p++)
                            {
                                next[l][p] += dp[l - m][p];
                            }
                        }
                    }
                    dp = next;
                }
                ans += dp[limsum][3];
            }
        }
        sw.WriteLine(ans);
        sw.Flush();
    }
}
0