結果

問題 No.967 引き算をして門松列(その2)
ユーザー dot_haraaidot_haraai
提出日時 2021-06-20 01:44:02
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 1,931 bytes
コンパイル時間 4,274 ms
コンパイル使用メモリ 76,320 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 01:17:36
合計ジャッジ時間 5,695 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 10 ms
4,376 KB
testcase_05 AC 10 ms
4,376 KB
testcase_06 AC 11 ms
4,376 KB
testcase_07 AC 11 ms
4,380 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 18) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'times' [UnusedImport]
/home/judge/data/code/Main.nim(2, 26) Warning: imported and not used: 'strformat' [UnusedImport]
/home/judge/data/code/Main.nim(2, 8) Warning: imported and not used: 'critbits' [UnusedImport]
/home/judge/data/code/Main.nim(2, 37) Warning: imported and not used: 'deques' [UnusedImport]
/home/judge/data/code/Main.nim(1, 41) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(2, 18) Warning: imported and not used: 'future' [UnusedImport]
/home/judge/data/code/Main.nim(1, 60) Warning: imported and not used: 'sets' [UnusedImport]
/home/judge/data/code/Main.nim(1, 66) Warning: imported and not used: 'lists' [UnusedImport]
/home/judge/data/code/Main.nim(1, 73) Warning: imported and not used: 'intsets' [UnusedImport]

ソースコード

diff #

import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets
import critbits, future, strformat, deques
template `max=`(x,y) = x = max(x,y)
template `min=`(x,y) = x = min(x,y)
template `mod=`(x,y) = x = x mod y
template scan2 = (scan(), scan())
template scan3 = (scan(), scan())
let read* = iterator: string {.closure.} =
    while true: (for s in stdin.readLine.split: yield s)
proc scan(): int = read().parseInt
proc scanf(): float = read().parseFloat
proc toInt(c:char): int =
    return int(c) - int('0')



var memo = initTable[(int,int,int),bool]()
proc dfs(a,b,c:int):bool=
  if memo.haskey((a,b,c)):
    return memo[(a,b,c)]
  if a==0 or b==0 or c==0:
    return false
  elif (a!=b and b!=c and c!=a) and ((a > b and b < c) or (a < b and b > c)):
    #echo fmt"{a} {b} {c}"
    return true
  else:
    memo[(a,b,c)]=dfs(a-1,b,c) or dfs(a,b-1,c) or dfs(a,b,c-1)
    return memo[(a,b,c)]

#for a in 1..100:
  #for b in 1..100:
    #for c in 1..100:
      #if dfs(a,b,c)==false:
        #echo fmt"{a} {b} {c}"


#echo dfs(2,2,3)

proc solve()=
  var
    t = scan()
    abcxyz = newseqwith(t,(scan(),scan(),scan(),scan(),scan(),scan()))
  for i in 0..<abcxyz.len:
    var
      (a,b,c,x,y,z)=abcxyz[i]
    if (a,b)==(1,1) or (a,b)==(1,2) or (b,c)==(1,1) or (b,c)==(2,1) or (a,c)==(1,1):
      echo -1
    else:
      var
        res = int.high.div(2)
        p1 = 0
        p2 = 0
      # 真ん中凸を作る
      if a>=b:
        p1+=(a-b+1)*x
        a = b-1
      if c>=b:
        p1+=(c-b+1)*z
        c = b-1
      if a==c:
        p1+=min(x,z)
        a-=1
      if not (a==0 or b==0 or c==0):
        res.min=p1
      # 真ん中凹を作る
      (a,b,c,x,y,z)=abcxyz[i]
      if a==c:
        p2+=min(x,z)
        a-=1
      if b>=min(a,c):
        p2+=(b-min(a,c)+1)*y
        b=min(a,c)-1
      if not (a==0 or b==0 or c==0):
        res.min=p1
      res.min=p2
      echo res




  
  
solve()
0