Submission #1836688


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 A - AtCoder Group Contest
User MitI_7
Language PyPy3 (2.4.0)
Score 0
Code Size 1389 Byte
Status RE
Exec Time 250 ms
Memory 41200 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
RE × 2
RE × 12
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
All 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt
Case Name Status Exec Time Memory
00_example_01.txt RE 250 ms 41200 KB
00_example_02.txt RE 183 ms 38512 KB
01.txt RE 182 ms 38512 KB
02.txt RE 180 ms 38512 KB
03.txt RE 177 ms 38512 KB
04.txt RE 180 ms 38512 KB
05.txt RE 179 ms 38512 KB
06.txt RE 181 ms 38512 KB
07.txt RE 182 ms 38512 KB
08.txt RE 181 ms 38512 KB
09.txt RE 186 ms 38512 KB
10.txt RE 177 ms 38512 KB