Problem 2610 --Basic Data Structures - Splice

2610: Basic Data Structures - Splice

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $272$ 正确数量 $159$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL

Splice

For n lists Li (i=0,1,...,n−1), perform a sequence of the following operations. 

insert(t, x): Insert an integer x at the end of Lt. 

dump(t): Print all elements in Lt. 

splice(s, t): Transfer elements of Ls to the end of Lt. Ls becomes empty. 

In the initial state, Li (i=0,1,...,n−1) are empty.

The input is given in the following format. 

n q 

query1 

query2 

queryq 

Each query queryi is given by 0 t x or 1 t or 2 s t where the first digits 0, 1 and 2 represent insert, dump and splice operations respectively. 

1≤n≤1,000 1≤q≤500,000 

For a splice operation, s≠t For a splice operation, Ls is not empty The total number of elements printed by dump operations do not exceed 1,000,000 −1,000,000,000≤x≤1,000,000,000

For each dump operation, print elements of the corresponding list in a line. Separete adjacency elements by a space character (do not print the space after the last element). Note that, if the list is empty, an empty line should be printed.
3 10
0 0 1
0 0 2
0 0 3
0 1 4
0 1 5
2 1 0
0 2 6
1 0
1 1
1 2
1 2 3 4 5

6

推荐代码 查看2610 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$237 $ms] AOJ大管家 281523 2018-10-07 08:23:55
内存最少[$16144 $KB] RUBY-WOO 360048 2019-01-14 19:46:27
第一AC 计爱玲 281521 2018-10-06 21:57:16
第一挑战 计爱玲 281521 2018-10-06 21:57:16

赛题来源/所属竞赛 会津大学《C++ Programming II》 C++程序设计(高级)

竞赛编号 竞赛名称 竞赛时间 访问比赛
1680 2021-2022-2学期<算法分析与设计> 第1周练习:STL容器1:vetor/list/queue/deque/sort 2022-02-21 08:00:00 请登录