UVA12657 移动盒子 Boxes in a Line 洛谷题面 开始交了一发 STL−ListSTL−List 想水掉,结果给 RERE 飞了。 于是老老实实手打结构体链表。 题目大意 你有nn 个盒子在桌子上的一条线上从左到右编号为 1⋯n1⋯n。你的任务是模拟四种操作: 1 X Y:移动盒子编号 XX 到盒子编号 YY 的左边(如果 XX 已经在
UVA 12657 Boxes in a Line You have n boxes in a line on the table numbered 1 . . . n from left to right. Your task is to simulate 4kinds of commands:•
对于4号命令,逆转整个序列,并没有真正的逆转,而是用inv 记录 是否逆转,利用了逆转两次等于没有逆转这个道理。逆转只会影响到1命令和2命令,3命令是XY换一下,并不会影响到,所以对与1和2,直接op = 3 - op即可!利用inv这个变量也有利于最后的输出,最后输出发现inv是0的话,就是没逆转,那么直接把奇数位置的数加...
You have n boxes in a line on the table numbered 1 . . . n from left to right. Your task is to simulate 4kinds of commands: • 1 X Y : move box X to the left to Y (ignore this if X is already the left of Y ) • 2 X Y : move box X to the right to Y (ignore...