Submission #2402763


Source Code Expand

# import sequtils, strutils, strscans, algorithm, math, future, sets, queues, tables # for yukicoder (0.17.1)
import sequtils, strutils, algorithm, math, future, sets, queues, tables # for AtCoder (0.13.0)
template getLine: string = stdin.readLine
template getInteger: int = getLine.parseInt
template getBiggestInteger: int64 = getLine.parseBiggestInt
template getIntSeq: seq[int] = getLine.split.map(parseInt)
template getBigIntSeq: seq[int64] = getLine.split.map(parseBiggestInt)

proc powmod[T](x, k, m: T): T =
  if k == 0:
    result = 1
  elif k mod 2 == 0:
    let x = powmod(x, k shr 1, m)
    result = x * x mod m
  else:
    result = powmod(x, k-1, m) * x mod m

proc inv[T](x: T, modulo: T = 1e9.int + 7): T =
  return powmod(x, modulo - 2, modulo)

proc popcount[T: int64|int](a: T): cint {. importc: "__builtin_popcountl", nodecl, nosideeffect.}

proc comb(n, k: int, modulo: int64, fact, inv_fact: seq[int64]): int64 =
  if n <= 0 or k < 0 or n < k:
    return 0
  return fact[n] * inv_fact[k] mod modulo * inv_fact[n - k] mod modulo

when isMainModule:
  let
    modulo = 1e9.int64 + 7.int64
    tmp = getIntSeq
    (R, C) = (tmp[0], tmp[1])
    tmp2 = getIntSeq
    (X, Y) = (tmp2[0], tmp2[1])
    tmp3 = getIntSeq
    (D, L) = (tmp3[0], tmp3[1])
  var fact, inv_fact = newSeq[int64](X * Y + 1)
  fact[0] = 1
  inv_fact[0] = inv(1)
  var fact_i = 1.int64
  for i in 1..(X * Y).int:
    fact_i = (fact_i * i.int64) mod modulo
    fact[i] = fact_i
    inv_fact[i] = inv(fact_i, modulo)

  var ans = 0.int64
  for state in 0..<(1 shl 4):
    let
      x = X - (state shr 0 and 1) - (state shr 1 and 1)
      y = Y - (state shr 2 and 1) - (state shr 3 and 1)
    var cc = comb(x * y, D, modulo, fact, inv_fact) * comb(x * y - D, L, modulo, fact, inv_fact) mod modulo
    if state.popcount mod 2 == 0:
      ans = (ans + cc) mod modulo
    else:
      ans = (ans - cc + modulo) mod modulo
  echo(ans * (R - X + 1) mod modulo * (C - Y + 1) mod modulo)

Submission Info

Submission Time
Task D - AtCoder社の冬
User n_knuu
Language Nim (0.13.0)
Score 0
Code Size 2018 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Compile Error

Hint: system [Processing]
Hint: Main [Processing]
Hint: sequtils [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: algorithm [Processing]
Hint: math [Processing]
Hint: times [Processing]
Hint: future [Processing]
Hint: macros [Processing]
Hint: sets [Processing]
Hint: os [Processing]
Hint: posix [Processing]
Hint: hashes [Processing]
Hint: etcpriv [Processing]
Hint: queues [Processing]
Hint: tables [Processing]
Main.nim(4, 10) Hint: 'getInteger' is declared but not used [XDeclaredButNotUsed]
Main.nim(5, 10) Hint: 'getBiggestInteger' is declared but not used [XDeclaredButNotUsed]
Main.nim(7, 10) Hint: 'getBigIntSeq' is declared but not used [XDeclaredButNotUsed]
Hint:  [Link]
Hint: operation successful (24537 lines compiled; 2.180 sec total; 23.235MB; Release Build) [SuccessX]

Judge Result

Set Name sub All
Score / Max Score 0 / 100 0 / 1
Status
AC × 21
WA × 4
AC × 48
WA × 4
Set Name Test Cases
sub 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, test_03E.txt, test_04E.txt, test_07E.txt, test_08E.txt, test_11E.txt, test_12E.txt, test_15E.txt, test_16E.txt, test_19E.txt, test_20E.txt, test_23E.txt, test_24E.txt, test_27E.txt, test_28E.txt, test_31E.txt, test_32E.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_45E.txt, test_47E.txt
All 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, 00_sample_04.txt, test_01.txt, test_02.txt, test_03E.txt, test_04E.txt, test_05.txt, test_06.txt, test_07E.txt, test_08E.txt, test_09.txt, test_10.txt, test_11E.txt, test_12E.txt, test_13.txt, test_14.txt, test_15E.txt, test_16E.txt, test_17.txt, test_18.txt, test_19E.txt, test_20E.txt, test_21.txt, test_22.txt, test_23E.txt, test_24E.txt, test_25.txt, test_26.txt, test_27E.txt, test_28E.txt, test_29.txt, test_30.txt, test_31E.txt, test_32E.txt, test_33.txt, test_34.txt, test_35.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45E.txt, test_46.txt, test_47E.txt, test_48.txt
Case Name Status Exec Time Memory
00_sample_01E.txt AC 1 ms 256 KB
00_sample_02E.txt WA 1 ms 256 KB
00_sample_03E.txt AC 1 ms 256 KB
00_sample_04.txt AC 1 ms 256 KB
test_01.txt AC 1 ms 256 KB
test_02.txt AC 1 ms 256 KB
test_03E.txt AC 1 ms 256 KB
test_04E.txt AC 1 ms 256 KB
test_05.txt AC 1 ms 256 KB
test_06.txt AC 1 ms 256 KB
test_07E.txt AC 1 ms 256 KB
test_08E.txt AC 1 ms 256 KB
test_09.txt AC 1 ms 256 KB
test_10.txt AC 1 ms 256 KB
test_11E.txt AC 1 ms 256 KB
test_12E.txt AC 1 ms 256 KB
test_13.txt AC 1 ms 256 KB
test_14.txt AC 1 ms 256 KB
test_15E.txt AC 1 ms 256 KB
test_16E.txt AC 1 ms 256 KB
test_17.txt AC 1 ms 256 KB
test_18.txt AC 1 ms 256 KB
test_19E.txt AC 1 ms 256 KB
test_20E.txt AC 1 ms 256 KB
test_21.txt AC 1 ms 256 KB
test_22.txt AC 1 ms 256 KB
test_23E.txt AC 1 ms 256 KB
test_24E.txt AC 1 ms 256 KB
test_25.txt AC 1 ms 256 KB
test_26.txt AC 1 ms 256 KB
test_27E.txt AC 1 ms 256 KB
test_28E.txt AC 1 ms 256 KB
test_29.txt AC 1 ms 256 KB
test_30.txt AC 1 ms 256 KB
test_31E.txt AC 1 ms 256 KB
test_32E.txt AC 1 ms 256 KB
test_33.txt AC 1 ms 256 KB
test_34.txt AC 1 ms 256 KB
test_35.txt AC 1 ms 256 KB
test_36E.txt AC 1 ms 256 KB
test_37E.txt WA 1 ms 256 KB
test_38E.txt AC 1 ms 256 KB
test_39E.txt WA 1 ms 256 KB
test_40.txt AC 1 ms 256 KB
test_41.txt AC 1 ms 256 KB
test_42.txt AC 1 ms 256 KB
test_43.txt AC 1 ms 256 KB
test_44.txt AC 1 ms 256 KB
test_45E.txt WA 1 ms 256 KB
test_46.txt AC 1 ms 256 KB
test_47E.txt AC 1 ms 256 KB
test_48.txt AC 1 ms 256 KB