Submission #260414


Source Code Expand

Copy
# -*- coding: utf-8 -*-
from collections import deque

N = int(raw_input())
edge = {}
for _ in xrange(N):
    l, m, s = raw_input().split()
    edge.setdefault(l, {s: int(m)})

# 一番遠いのを取得する

def bfs(start):
    queue = deque()
    queue.append((start, 1))
    mx = 0
    far_node = ""
    while len(queue) > 0:
        current, a = queue.pop()
        if mx < a:
            mx = a
            far_node = current

        if edge.has_key(current):
            for (nxt, nxt_value) in edge[current].iteritems():
                queue.append((nxt, a * nxt_value))

    return far_node, mx


mxCost = 0
ans = ""
for key, value in edge.iteritems():
    far, cost = bfs(key)
    if cost > mxCost:
        mxCost = max(mxCost, cost)
        ans = "1" + key + "=" + str(mxCost) + far
print  ans

Submission Info

Submission Time
Task C - 変わった単位
User yuki2006
Language Python (2.7.3)
Score 0
Code Size 843 Byte
Status
Exec Time 2032 ms
Memory 3672 KB

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 100 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, chokudai_solo_01.txt, chokudai_solo_02.txt, chokudai_solo_03.txt, chokudai_vs_cucumber_01.txt, chokudai_vs_cucumber_02.txt, chokudai_vs_cucumber_03.txt, chokudai_vs_cucumber_04.txt, chokudai_vs_cucumber_05.txt, chokudai_vs_kensho_01.txt, chokudai_vs_kensho_02.txt, chokudai_vs_kensho_03.txt, chokudai_vs_kensho_04.txt, chokudai_vs_kensho_05.txt, chokudai_vs_kensho_06.txt, chokudai_vs_kensho_07.txt, chokudai_vs_kensho_08.txt, chokudai_vs_kensho_09.txt, chokudai_vs_laycurse_01.txt, chokudai_vs_laycurse_02.txt, chokudai_vs_laycurse_03.txt, chokudai_vs_sanagipp_01.txt, chokudai_vs_sanagipp_02.txt, chokudai_vs_sanagipp_03.txt, chokudai_vs_sanagipp_04.txt, chokudai_vs_takahashikun_01.txt, chokudai_vs_takahashikun_02.txt, chokudai_vs_takahashikun_03.txt, chokudai_vs_takahashikun_04.txt, chokudai_vs_uwitenpen_01.txt, chokudai_vs_uwitenpen_02.txt, chokudai_vs_uwitenpen_03.txt
Case Name Status Exec Time Memory
00_sample_01.txt 51 ms 3616 KB
00_sample_02.txt 51 ms 3608 KB
00_sample_03.txt 52 ms 3612 KB
chokudai_solo_01.txt 52 ms 3608 KB
chokudai_solo_02.txt 2032 ms 3540 KB
chokudai_solo_03.txt 2032 ms 3540 KB
chokudai_vs_cucumber_01.txt 54 ms 3560 KB
chokudai_vs_cucumber_02.txt 2030 ms 3540 KB
chokudai_vs_cucumber_03.txt 2030 ms 3492 KB
chokudai_vs_cucumber_04.txt 2031 ms 3608 KB
chokudai_vs_cucumber_05.txt 2030 ms 3560 KB
chokudai_vs_kensho_01.txt 51 ms 3564 KB
chokudai_vs_kensho_02.txt 53 ms 3612 KB
chokudai_vs_kensho_03.txt 54 ms 3620 KB
chokudai_vs_kensho_04.txt 54 ms 3604 KB
chokudai_vs_kensho_05.txt 2031 ms 3560 KB
chokudai_vs_kensho_06.txt 2030 ms 3564 KB
chokudai_vs_kensho_07.txt 54 ms 3672 KB
chokudai_vs_kensho_08.txt 2030 ms 3540 KB
chokudai_vs_kensho_09.txt 2031 ms 3492 KB
chokudai_vs_laycurse_01.txt 52 ms 3600 KB
chokudai_vs_laycurse_02.txt 53 ms 3608 KB
chokudai_vs_laycurse_03.txt 53 ms 3608 KB
chokudai_vs_sanagipp_01.txt 54 ms 3612 KB
chokudai_vs_sanagipp_02.txt 51 ms 3604 KB
chokudai_vs_sanagipp_03.txt 53 ms 3604 KB
chokudai_vs_sanagipp_04.txt 53 ms 3612 KB
chokudai_vs_takahashikun_01.txt 52 ms 3604 KB
chokudai_vs_takahashikun_02.txt 53 ms 3612 KB
chokudai_vs_takahashikun_03.txt 53 ms 3600 KB
chokudai_vs_takahashikun_04.txt 53 ms 3604 KB
chokudai_vs_uwitenpen_01.txt 51 ms 3568 KB
chokudai_vs_uwitenpen_02.txt 49 ms 3540 KB
chokudai_vs_uwitenpen_03.txt 49 ms 3604 KB