結果
問題 | No.763 Noelちゃんと木遊び |
ユーザー | むらため |
提出日時 | 2019-01-30 02:11:42 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 1,388 bytes |
コンパイル時間 | 2,753 ms |
コンパイル使用メモリ | 66,464 KB |
実行使用メモリ | 22,084 KB |
最終ジャッジ日時 | 2023-09-14 03:13:22 |
合計ジャッジ時間 | 4,520 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
22,084 KB |
testcase_01 | AC | 10 ms
6,284 KB |
testcase_02 | AC | 31 ms
10,668 KB |
testcase_03 | AC | 17 ms
8,160 KB |
testcase_04 | AC | 11 ms
6,852 KB |
testcase_05 | AC | 16 ms
8,028 KB |
testcase_06 | AC | 39 ms
12,004 KB |
testcase_07 | AC | 41 ms
11,688 KB |
testcase_08 | AC | 17 ms
8,492 KB |
testcase_09 | AC | 11 ms
6,596 KB |
testcase_10 | AC | 5 ms
4,532 KB |
testcase_11 | AC | 43 ms
12,328 KB |
testcase_12 | AC | 34 ms
11,268 KB |
testcase_13 | AC | 35 ms
11,144 KB |
testcase_14 | AC | 35 ms
10,256 KB |
testcase_15 | AC | 16 ms
7,984 KB |
testcase_16 | AC | 4 ms
4,380 KB |
testcase_17 | AC | 17 ms
8,216 KB |
testcase_18 | AC | 40 ms
12,128 KB |
testcase_19 | AC | 35 ms
11,384 KB |
testcase_20 | AC | 36 ms
11,380 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
ソースコード
import sequtils,times,lists template times*(n:int,body) = (for _ in 0..<n: body) template `max=`*(x,y) = x = max(x,y) template `min=`*(x,y) = x = min(x,y) template stopwatch(body) = (let t1 = cpuTime();body;echo "TIME:",(cpuTime() - t1) * 1000,"ms") template stopwatch(body) = body proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord # 31634 let n = scan() var E : array[100010,SinglyLinkedList[int]] var preHasCutDP : array[100010,int] var preHasNotCutDP : array[100010,int] stopwatch: (n-1).times: let u = scan() - 1 let v = scan() - 1 E[u].prepend(v) E[v].prepend(u) for i in 0..<n: preHasCutDP[i] = -1 preHasNotCutDP[i] = -1 proc solve(preHasCut:bool,x:int,preX:int):int = if preHasCut and preHasCutDP[x] != -1 : return preHasCutDP[x] if not preHasCut and preHasNotCutDP[x] != -1 : return preHasNotCutDP[x] var whenCut = 0 for e in E[x]: if e != preX : whenCut += solve(true,e,x) var whenNotCut = 0 for e in E[x]: if e != preX : whenNotCut += solve(false,e,x) preHasCutDP[x] = max(whenCut,whenNotCut+1) preHasNotCutDP[x] = max(whenCut,whenNotCut) if preHasCut : whenNotCut += 1 result = max(whenCut,whenNotCut) stopwatch: echo solve(true,0,-1)