当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3704:Mover

Special Judge 特殊评判
题目描述

Given a board of N × N cells, each cell may contain at most one piece. For the purpose of this problem, two pieces A and B are directly connected if their cells share a common edge. Two pieces A and B are connected indirectly if there exists another piece C such that A and C are connected (indirectly or directly) and B and C are connected (indirectly or directly). Write a program to use no more than 50000 instructions to make all pieces connected (indirectly or directly) with each other.

Each instruction can move one piece to an empty cell, which shares a common edge.

输入解释

The first line of input contains two integers N, M, denoting the size of board and the number of pieces on the board. 1 ≤ N ≤ 100, 1 ≤ MN × N
Following m lines, each contains two numbers X,Y, denoting the position of one piece. All (X,Y) will be distinct. 0 < X,Y N

输出解释

The first line of output contains one integer C denoting the number of instructions.
Following C lines, each contains four numbers X1, Y1, X2, Y2 for one instruction, which will move the piece in (X1,Y1) to (X2,Y2). If there are many such instructions, you can output any one of them.

输入样例
4 4
1 1
2 2
3 3
4 4
输出样例
4
1 1 2 1
4 4 3 4
3 4 2 4
2 4 2 3

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3704

最后修改于 2020-10-29T07:08:36+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536