結果

問題 No.30 たこやき工場
ユーザー 6soukiti296soukiti29
提出日時 2017-07-27 11:18:56
言語 Nim
(2.0.2)
結果
AC  
実行時間 1,428 ms / 5,000 ms
コード長 894 bytes
コンパイル時間 4,443 ms
コンパイル使用メモリ 71,700 KB
実行使用メモリ 36,012 KB
最終ジャッジ日時 2023-08-23 05:19:24
合計ジャッジ時間 6,651 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1,428 ms
36,012 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils,deques

type
    item = tuple[id : int, oya : seq[int], ko : seq[int]]
    zairyou = tuple[oya : int, num : int]
var
    N = stdin.readline.parseInt
    M = stdin.readline.parseInt
    P,Q,R : int
    cnt : array[101,int]
    flag : array[101,bool]
    Items = newSeq[item](N + 1)
    hyou : array[101,array[101,int]]
    p : item
    j : int

for i,t in Items:
    Items[i] = (i,newSeq[int](0),newSeq[int](0))

cnt[N] = 1
for n in 0..<M:
    (P,Q,R) = stdin.readline.split.map(parseInt)
    flag[R] = true
    Items[P].oya.add(R)
    Items[R].ko.add(P)
    hyou[P][R] = Q
    
var q = initDeque[int](4)

q.addLast(N)

while q.len > 0:
    j = q.popFirst
    p = Items[j]
    if cnt[p.id] == 0 or flag[p.id] == false:
        continue
    for k in p.ko:
        cnt[k] += hyou[k][p.id] * cnt[p.id]
        q.addLast(k)
    cnt[p.id] = 0

for i in 1..<N:
    echo cnt[i]
0