Problem 2617 --Basic Modifications - Swap

2617: Basic Modifications - Swap

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $11$ 正确数量 $11$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL
Swap Write a program which reads a sequence of integers A={a0,a1,...,an−1} and swap specified elements by a list of the following operation: swapRange(b,e,t): For each integer k (0≤k<(e−b), swap element (b+k) and element (t+k).

The input is given in the following format. 

a0 a1...,an−1

b1 e1 t1

b2 e2 t2

 : 

bq eq tq

 In the first line, n (the number of elements in A) is given. In the second line, ai (each element in A) are given. In the third line, the number of queries q is given and each query is given by three integers bi ei ti in the following q lines.

Print all elements of A in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element.
11
1 2 3 4 5 6 7 8 9 10 11
1
1 4 7
1 8 9 10 5 6 7 2 3 4 11

1≤n≤1,000 −1,000,000,000≤ai≤1,000,000,000 1≤q≤1,000 0≤bi

swap_ranges(A.begin() + b, A.begin()+m,A.begin() + e);

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

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] Qiqy 608900 2020-07-29 17:19:05
内存最少[$2016 $KB] 刘 涛 338842 2018-12-06 10:04:12
第一AC 计爱玲 281713 2018-10-07 15:29:19
第一挑战 计爱玲 281713 2018-10-07 15:29:19

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

竞赛编号 竞赛名称 竞赛时间 访问比赛