結果

問題 No.398 ハーフパイプ(2)
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-30 07:54:47
言語 D
(dmd 2.106.1)
結果
MLE  
実行時間 -
コード長 1,866 bytes
コンパイル時間 966 ms
コンパイル使用メモリ 106,404 KB
実行使用メモリ 495,324 KB
最終ジャッジ日時 2023-09-03 23:22:02
合計ジャッジ時間 17,185 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum N = 6;
enum L = 100;

void main() {
  auto dp = new long[][][][](N, L + 1, L + 1, N * L + 1);
  foreach (k; 0 .. L + 1) {
    dp[0][k][k][k] = 1;
  }
  foreach (i; 1 .. N) {
    foreach (x; 0 .. L + 1) foreach (y; x .. L + 1) foreach (z; 0 .. N * L + 1) {
      if (dp[i - 1][x][y][z] != 0) {
        foreach (k; 0 .. L + 1) {
          dp[i][min(x, k)][max(y, k)][z + k] += dp[i - 1][x][y][z];
        }
      }
    }
  }
  
  try {
    for (; ; ) {
      const X = readReal();
      long ans;
      foreach (x; 0 .. L + 1) foreach (y; 0 .. L + 1) foreach (z; 0 .. N * L + 1) {
        if ((z - x - y) / 4.0 == X) {
          ans += dp[N - 1][x][y][z];
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}
0