旅程AI (CI翻译)
The territory of Berland is represented by a rectangular field $*n* × *m*$ in size. The king of Berland lives in the capital, located on the upper left square $(1, 1)$. The lower right square has coordinates $(*n*, *m*)$. One day the king decided to travel through the whole country and return back to the capital, having visited every square (except the capital) exactly one time. The king must visit the capital exactly two times, at the very beginning and at the very end of his journey. The king can only move to the side-neighboring squares. However, the royal advise said that the King possibly will not be able to do it. But there is a way out — one can build the system of one way teleporters between some squares so that the king could fulfill his plan. No more than one teleporter can be installed on one square, every teleporter can be used any number of times, however every time it is used, it transports to the same given for any single teleporter square. When the king reaches a square with an installed teleporter he chooses himself whether he is or is not going to use the teleport. What minimum number of teleporters should be installed for the king to complete the journey? You should also compose the journey path route for the king.
Input
输入格式
AI (CI翻译)The first line contains two space-separated integers $*n*$ and $*m*$ ($1 ≤ *n*, *m* ≤ 100, 2 ≤$ $*n*$ $·$ $*m*$) — the field size. The upper left square has coordinates $(1, 1)$, and the lower right square has coordinates of $(*n*, *m*)$.
第一行包含两个用空格分隔的整数 $*n*$ 和 $*m*$($1 ≤ *n*, *m* ≤ 100,$2 ≤$ $n$ $·$ $m$),表示区域的大小。左上角方格的坐标为 $(1, 1)$,右下角方格的坐标为 $(n, m)$。AI (CI翻译)
Output
输出格式
AI (CI翻译)On the first line output integer $*k*$ — the minimum number of teleporters. Then output $*k*$ lines each containing 4 integers $*x*_{1}$ $*y*_{1}$ $*x*_{2}$ $*y*_{2}$ ($1 ≤ *x*_{1}, *x*_{2} ≤ *n*, 1 ≤ *y*_{1}, *y*_{2} ≤ *m*$) — the coordinates of the square where the teleporter is installed ($*x*_{1}, *y*_{1}$), and the coordinates of the square where the teleporter leads ($*x*_{2}, *y*_{2}$).
第一行输出整数 $*k*$,表示传送器的最少数量。接下来 $*k*$ 行,每行包含 4 个整数 $*x*_{1}$ $*y*_{1}$ $*x*_{2}$ $*y*_{2}$($1 ≤ *x*_{1}, *x*_{2} ≤ *n*$,$1 ≤ *y*_{1}, *y*_{2} ≤ *m*$),分别表示传送器安装方格的坐标($*x*_{1}, *y*_{1}$)以及传送器的目标方格坐标($*x*_{2}, *y*_{2}$)。AI (CI翻译)
Then print $*nm* + 1$ lines containing 2 numbers each — the coordinates of the squares in the order in which they are visited by the king. The travel path must start and end at $(1, 1)$. The king can move to side-neighboring squares and to the squares where a teleporter leads. Besides, he also should visit the capital exactly two times and he should visit other squares exactly one time.
然后输出 $*nm* + 1$ 行,每行包含 2 个数字,表示国王依次访问的方格坐标。旅程必须从 $(1, 1)$ 出发并在 $(1, 1)$ 结束。国王可以移动到共边的相邻方格,也可以移动到传送器的目标方格。此外,国王必须恰好访问首都两次,其他方格均恰好访问一次。AI (CI翻译)
样例
2 2
0
1 1
1 2
2 2
2 1
1 1
3 3
1
3 3 1 1
1 1
1 2
1 3
2 3
2 2
2 1
3 1
3 2
3 3
1 1
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。