Problem 3043 --Acesrc and Hunting

3043: Acesrc and Hunting

"
Time Limit $2$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $8$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Acesrc is a famous hunter at Nanjing University second to none. Recently, he set n×mn×m traps in Yangshan Park, a park near Nanjing University Xianlin Campus, arranged in nn rows and mm columns. The rows are numbered 11 through nn from bottom to up, and the columns are numbered 11 through mm from left to right. The distance between two adjacent traps, both horizontally and vertically, is 1 meter. 

Today, Acesrc happily finds that every trap he set has captured an animal. He decides to collect these hunted animals to make roast meat for his friends. However, collecting these animals normally is too boring, so he decides to find a route following the rules below: 

1. Acesrc can choose any trap to start; every time he collects the animal in the trap, he moves to some unvisited trap and repeats until all captured animals are collected; 
2. The Euclidean distance he moves from one trap to the next trap should be between 1 meter and 3 meters exclusive; that is, the distance should be strictly greater than 1 meter and strictly less than 3 meters. 

Acesrc has quickly collected all animals. Roo wonders how Acesrc collected these animals, but Acesrc buttons up his lip. Can you give a possible route to collect all the animals?
The first line of input consists of a single integer TT (1≤T≤240)(1≤T≤240), the number of test cases. Each test case is a single line of two integers n,mn,m (1≤n,m≤100)(1≤n,m≤100), denoting the size of the trap matrix.
For each test case, if it is impossible to find any valid route, print NO in a single line; otherwise, print YES in one line, followed by n×mn×m lines describing the route, each of these lines containing two integers x,yx,y (1≤x≤n,1≤y≤m)(1≤x≤n,1≤y≤m), denoting the position of a trap visited. If multiple solutions exist, print any.
2
2 2
2 3
NO
YES
1 1
2 2
1 3
2 1
1 2
2 3

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

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战 淡意的温柔 591129 2020-06-06 08:31:04

赛题来源/所属竞赛 2019 Multi-University Training Contest 8 N/A

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