Submission #66966049


Source Code Expand

import sys
import os
from math import ceil, floor, sqrt, pi, factorial, gcd,lcm,sin,cos,tan,asin,acos,atan2,exp,log,log10, isqrt, comb
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import cmp_to_key, lru_cache, reduce, cache
from operator import add, iand, ior, itemgetter, mul, xor
from string import ascii_lowercase, ascii_uppercase, ascii_letters
from typing import *
from bisect import bisect, bisect_left, bisect_right
from heapq import heapify, heappop, heappush, heappushpop, nlargest, nsmallest
from sortedcontainers import SortedSet, SortedList, SortedDict
from itertools import product, accumulate,permutations,combinations, count, groupby
from dataclasses import dataclass
input = lambda: sys.stdin.readline().rstrip("\r\n")
I = input
II = lambda: int(I())
LI = lambda: list(input().split())
LII = lambda: list(map(int, input().split()))
sys.setrecursionlimit(10000000)
inf = float('inf')

N,Q = LII()

@dataclass
class TrieNode:
    children: dict
    s : str
    parent: dict

sv = None
PC = [None]*N
for _ in range(Q):
    q = LI()
    if q[0]=="1":
        p = int(q[1])
        PC[p-1] = sv
    elif q[0]=="2":
        p = int(q[1])
        s = q[2]
        new_node = TrieNode(None,s,PC[p-1])
        if PC[p-1]:
            PC[p-1].children = new_node
        PC[p-1]= new_node
    else:
        p = int(q[1])
        sv = PC[p-1]

ans = []
while sv:
    ans.append(sv.s)
    sv = sv.parent

print("".join(ans[::-1]))

Submission Info

Submission Time
Task D - Conflict 2
User GeekMasahiro
Language Python (PyPy 3.10-v7.3.12)
Score 425
Code Size 1482 Byte
Status AC
Exec Time 339 ms
Memory 138904 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 49
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 04_random4_00.txt, 04_random4_01.txt, 05_random5_00.txt, 05_random5_01.txt, 06_handmade_00.txt, 06_handmade_01.txt, 06_handmade_02.txt, 06_handmade_03.txt, 06_handmade_04.txt, 06_handmade_05.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 211 ms 95904 KiB
00_sample_01.txt AC 217 ms 96632 KiB
00_sample_02.txt AC 207 ms 95692 KiB
01_random_00.txt AC 228 ms 97600 KiB
01_random_01.txt AC 263 ms 100888 KiB
01_random_02.txt AC 263 ms 101480 KiB
01_random_03.txt AC 220 ms 97816 KiB
01_random_04.txt AC 273 ms 103236 KiB
01_random_05.txt AC 231 ms 97340 KiB
01_random_06.txt AC 224 ms 96808 KiB
01_random_07.txt AC 229 ms 96316 KiB
01_random_08.txt AC 287 ms 100588 KiB
01_random_09.txt AC 262 ms 99860 KiB
01_random_10.txt AC 254 ms 97604 KiB
01_random_11.txt AC 237 ms 96760 KiB
01_random_12.txt AC 271 ms 100440 KiB
01_random_13.txt AC 261 ms 99924 KiB
01_random_14.txt AC 265 ms 101620 KiB
01_random_15.txt AC 252 ms 98496 KiB
02_random2_00.txt AC 305 ms 108676 KiB
02_random2_01.txt AC 308 ms 109052 KiB
02_random2_02.txt AC 295 ms 108852 KiB
02_random2_03.txt AC 305 ms 109056 KiB
02_random2_04.txt AC 310 ms 116284 KiB
02_random2_05.txt AC 313 ms 110980 KiB
02_random2_06.txt AC 296 ms 108100 KiB
02_random2_07.txt AC 298 ms 104408 KiB
02_random2_08.txt AC 339 ms 129404 KiB
02_random2_09.txt AC 321 ms 115316 KiB
02_random2_10.txt AC 306 ms 107904 KiB
02_random2_11.txt AC 293 ms 101192 KiB
02_random2_12.txt AC 322 ms 135704 KiB
02_random2_13.txt AC 311 ms 118484 KiB
02_random2_14.txt AC 300 ms 107604 KiB
02_random2_15.txt AC 254 ms 98016 KiB
03_random3_00.txt AC 307 ms 112916 KiB
03_random3_01.txt AC 313 ms 113128 KiB
03_random3_02.txt AC 307 ms 112752 KiB
03_random3_03.txt AC 285 ms 109984 KiB
04_random4_00.txt AC 312 ms 115732 KiB
04_random4_01.txt AC 313 ms 115708 KiB
05_random5_00.txt AC 308 ms 138836 KiB
05_random5_01.txt AC 311 ms 138904 KiB
06_handmade_00.txt AC 215 ms 95884 KiB
06_handmade_01.txt AC 225 ms 100544 KiB
06_handmade_02.txt AC 264 ms 97676 KiB
06_handmade_03.txt AC 284 ms 108472 KiB
06_handmade_04.txt AC 278 ms 97984 KiB
06_handmade_05.txt AC 291 ms 109360 KiB