Submission #1836676


Source Code Expand

import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍(右, 下, 左, 上)
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


color, depth, graph = [], [], {}
def func(v, d, c):
    if not color[v]:
        color[v] = c
    if depth[v] >= d or d == 0:
        return

    for u in graph[v]:
        func(u, d - 1, c)


def main():
    global color, depth, graph
    N, M = map(int, input().split())
    graph = defaultdict(list)
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        graph[a].append(b)
        graph[b].append(a)

    Q = int(input())
    q = []
    for _ in range(Q):
        v, d, c = map(int, input().split())
        q.append((v - 1, d, c))

    color = [0] * N
    depth = [0] * N
    for i in range(Q - 1, -1, -1):
        func(q[i][0], q[i][1], q[i][2])
    print(*color, sep="\n")

if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task B - Splatter Painting
User MitI_7
Language Python (3.4.3)
Score 0
Code Size 1328 Byte
Status TLE
Exec Time 2107 ms
Memory 42884 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
AC × 2
AC × 15
TLE × 4
AC × 17
TLE × 18
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
Subtask1 00_example_01.txt, 00_example_02.txt, 10_01.txt, 10_02.txt, 10_03.txt, 10_04.txt, 10_05.txt, 10_06.txt, 10_07.txt, 10_08.txt, 10_09.txt, 10_10.txt, 10_11.txt, 10_12.txt, 10_13.txt, 10_14.txt, 10_15.txt, 10_16.txt, 10_17.txt
All 00_example_01.txt, 00_example_02.txt, 10_01.txt, 10_02.txt, 10_03.txt, 10_04.txt, 10_05.txt, 10_06.txt, 10_07.txt, 10_08.txt, 10_09.txt, 10_10.txt, 10_11.txt, 10_12.txt, 10_13.txt, 10_14.txt, 10_15.txt, 10_16.txt, 10_17.txt, 20_01.txt, 20_02.txt, 20_03.txt, 20_04.txt, 20_05.txt, 20_06.txt, 20_07.txt, 20_08.txt, 20_09.txt, 20_10.txt, 20_11.txt, 20_12.txt, 20_13.txt, 20_14.txt, 20_15.txt, 20_16.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 29 ms 3952 KB
00_example_02.txt AC 27 ms 3952 KB
10_01.txt TLE 2104 ms 3952 KB
10_02.txt AC 27 ms 3948 KB
10_03.txt AC 27 ms 3952 KB
10_04.txt AC 27 ms 3948 KB
10_05.txt TLE 2104 ms 3948 KB
10_06.txt AC 339 ms 3952 KB
10_07.txt AC 28 ms 4204 KB
10_08.txt AC 1218 ms 4952 KB
10_09.txt AC 1009 ms 4852 KB
10_10.txt AC 904 ms 4976 KB
10_11.txt AC 1829 ms 4844 KB
10_12.txt AC 1265 ms 4960 KB
10_13.txt AC 86 ms 4716 KB
10_14.txt AC 107 ms 4580 KB
10_15.txt AC 66 ms 4588 KB
10_16.txt TLE 2104 ms 4464 KB
10_17.txt TLE 2104 ms 4468 KB
20_01.txt TLE 2107 ms 37344 KB
20_02.txt TLE 2105 ms 39352 KB
20_03.txt TLE 2107 ms 37304 KB
20_04.txt TLE 2104 ms 8188 KB
20_05.txt TLE 2104 ms 4468 KB
20_06.txt AC 83 ms 8968 KB
20_07.txt TLE 2104 ms 4716 KB
20_08.txt TLE 2105 ms 12096 KB
20_09.txt AC 1199 ms 4844 KB
20_10.txt TLE 2105 ms 11800 KB
20_11.txt TLE 2105 ms 15532 KB
20_12.txt TLE 2106 ms 30656 KB
20_13.txt TLE 2107 ms 37368 KB
20_14.txt TLE 2107 ms 39664 KB
20_15.txt TLE 2107 ms 42884 KB
20_16.txt TLE 2107 ms 42824 KB