307357: CF1345A. Puzzle Pieces
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Puzzle Pieces
题意翻译
## 题意简述 给你一种拼图玩具。每个小拼图有三个凸和一个凹,就像下面的那张图片。 现在给定$n,m$,要求你判断是否可以用$n\cdot m$个小拼图拼成一张$n$行$m$列的大拼图使得小拼图之间的凹与凸总是匹配的(也就是没有重叠或空出的部分)。 你需要回答$t$组独立的测试用例。 (翻译by vectorwyx)题目描述
You are given a special jigsaw puzzle consisting of $ n\cdot m $ identical pieces. Every piece has three tabs and one blank, as pictured below. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1345A/60ffcef399717ed0f289e4b31cc0a5ee2dec5407.png)The jigsaw puzzle is considered solved if the following conditions hold: 1. The pieces are arranged into a grid with $ n $ rows and $ m $ columns. 2. For any two pieces that share an edge in the grid, a tab of one piece fits perfectly into a blank of the other piece. Through rotation and translation of the pieces, determine if it is possible to solve the jigsaw puzzle.输入输出格式
输入格式
The test consists of multiple test cases. The first line contains a single integer $ t $ ( $ 1\le t\le 1000 $ ) — the number of test cases. Next $ t $ lines contain descriptions of test cases. Each test case contains two integers $ n $ and $ m $ ( $ 1 \le n,m \le 10^5 $ ).
输出格式
For each test case output a single line containing "YES" if it is possible to solve the jigsaw puzzle, or "NO" otherwise. You can print each letter in any case (upper or lower).
输入输出样例
输入样例 #1
3
1 3
100000 100000
2 2
输出样例 #1
YES
NO
YES