Submission #1836648


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


def func(v, d, c, color, depth, graph):
    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, color, depth, graph)

def main():
    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 v, d, c in q[::-1]:
        func(v, d, c, color, depth, graph)
    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 1301 Byte
Status TLE
Exec Time 2106 ms
Memory 43608 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 × 18
TLE × 17
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 26 ms 3952 KB
00_example_02.txt AC 27 ms 3944 KB
10_01.txt TLE 2104 ms 3944 KB
10_02.txt AC 27 ms 3952 KB
10_03.txt AC 27 ms 3944 KB
10_04.txt AC 27 ms 3952 KB
10_05.txt TLE 2104 ms 3948 KB
10_06.txt AC 293 ms 3944 KB
10_07.txt AC 28 ms 4204 KB
10_08.txt AC 1103 ms 4844 KB
10_09.txt AC 903 ms 4840 KB
10_10.txt AC 803 ms 4844 KB
10_11.txt AC 1582 ms 4836 KB
10_12.txt AC 1179 ms 4968 KB
10_13.txt AC 80 ms 4712 KB
10_14.txt AC 100 ms 4584 KB
10_15.txt AC 62 ms 4588 KB
10_16.txt TLE 2104 ms 4576 KB
10_17.txt TLE 2104 ms 4556 KB
20_01.txt TLE 2106 ms 38156 KB
20_02.txt TLE 2106 ms 38148 KB
20_03.txt TLE 2105 ms 38052 KB
20_04.txt TLE 2104 ms 8228 KB
20_05.txt TLE 2104 ms 4588 KB
20_06.txt AC 79 ms 8960 KB
20_07.txt TLE 2104 ms 4712 KB
20_08.txt TLE 2104 ms 12616 KB
20_09.txt AC 953 ms 4708 KB
20_10.txt TLE 2104 ms 12356 KB
20_11.txt TLE 2104 ms 16308 KB
20_12.txt AC 1892 ms 30628 KB
20_13.txt TLE 2105 ms 40024 KB
20_14.txt TLE 2106 ms 40380 KB
20_15.txt TLE 2106 ms 43608 KB
20_16.txt TLE 2106 ms 43592 KB