Submission #1836766


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
    depth[v] = d
    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 Python (3.4.3)
Score 700
Code Size 1405 Byte
Status AC
Exec Time 1102 ms
Memory 39612 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 500 / 500
Status
AC × 2
AC × 19
AC × 35
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 3948 KB
00_example_02.txt AC 26 ms 3956 KB
10_01.txt AC 32 ms 3952 KB
10_02.txt AC 27 ms 3956 KB
10_03.txt AC 27 ms 3948 KB
10_04.txt AC 26 ms 3956 KB
10_05.txt AC 32 ms 3948 KB
10_06.txt AC 27 ms 3952 KB
10_07.txt AC 28 ms 4204 KB
10_08.txt AC 44 ms 4848 KB
10_09.txt AC 45 ms 4844 KB
10_10.txt AC 44 ms 4848 KB
10_11.txt AC 43 ms 4852 KB
10_12.txt AC 44 ms 4836 KB
10_13.txt AC 36 ms 4588 KB
10_14.txt AC 35 ms 4588 KB
10_15.txt AC 34 ms 4460 KB
10_16.txt AC 44 ms 4844 KB
10_17.txt AC 45 ms 4824 KB
20_01.txt AC 1102 ms 38288 KB
20_02.txt AC 1077 ms 38280 KB
20_03.txt AC 1083 ms 38312 KB
20_04.txt AC 271 ms 8488 KB
20_05.txt AC 47 ms 4592 KB
20_06.txt AC 101 ms 15048 KB
20_07.txt AC 51 ms 4768 KB
20_08.txt AC 298 ms 12084 KB
20_09.txt AC 47 ms 4708 KB
20_10.txt AC 265 ms 11824 KB
20_11.txt AC 371 ms 15524 KB
20_12.txt AC 498 ms 25228 KB
20_13.txt AC 838 ms 34200 KB
20_14.txt AC 886 ms 36248 KB
20_15.txt AC 942 ms 39612 KB
20_16.txt AC 1023 ms 39544 KB