Submission #1836689


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 = [[] for _ in range(N)]
    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 PyPy3 (2.4.0)
Score 0
Code Size 1389 Byte
Status TLE
Exec Time 2116 ms
Memory 123808 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
AC × 2
AC × 17
TLE × 2
AC × 21
TLE × 14
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 175 ms 38640 KB
00_example_02.txt AC 185 ms 40432 KB
10_01.txt AC 457 ms 50648 KB
10_02.txt AC 177 ms 38512 KB
10_03.txt AC 181 ms 38512 KB
10_04.txt AC 169 ms 38512 KB
10_05.txt AC 1430 ms 51416 KB
10_06.txt AC 296 ms 47324 KB
10_07.txt AC 193 ms 40944 KB
10_08.txt AC 725 ms 69080 KB
10_09.txt AC 683 ms 69080 KB
10_10.txt AC 714 ms 70872 KB
10_11.txt AC 894 ms 71660 KB
10_12.txt AC 731 ms 69464 KB
10_13.txt AC 391 ms 58072 KB
10_14.txt AC 373 ms 55768 KB
10_15.txt AC 351 ms 54872 KB
10_16.txt TLE 2106 ms 57116 KB
10_17.txt TLE 2107 ms 53848 KB
20_01.txt TLE 2111 ms 105760 KB
20_02.txt TLE 2111 ms 106656 KB
20_03.txt TLE 2111 ms 103072 KB
20_04.txt TLE 2108 ms 56408 KB
20_05.txt TLE 2109 ms 74328 KB
20_06.txt AC 333 ms 57120 KB
20_07.txt AC 1231 ms 79084 KB
20_08.txt TLE 2108 ms 67544 KB
20_09.txt AC 844 ms 74200 KB
20_10.txt TLE 2109 ms 82008 KB
20_11.txt TLE 2109 ms 74072 KB
20_12.txt AC 1500 ms 104812 KB
20_13.txt TLE 2112 ms 123808 KB
20_14.txt TLE 2116 ms 123500 KB
20_15.txt TLE 2110 ms 89504 KB
20_16.txt TLE 2110 ms 89760 KB