eolymp
bolt
Try our new interface for solving problems
Məsələlər

Queen Game

Queen Game

Queen game is played in a chessboard of size \textbf{R} rows and \textbf{C} columns. Rows are numbered from \textbf{1} to \textbf{R} and columns are numbered from \textbf{1} to \textbf{C}. The topmost square is in row \textbf{1} and column \textbf{1}. The game is a \textbf{2} player game. Initially there are N queens placed in various squares of the chessboard. In his turn, the player picks a queen and moves it either towards the top vertically, or towards the left horizontally or towards the top-left diagonally and the queen should always stay on the board. When the queen reaches square (\textbf{1}, \textbf{1}) it is removed from the board. The player who gives the last move wins. Each square is big enough to accommodate infinite number of queens. The players give their moves by turns. You are given the size of the chessboard and the initial positions of the \textbf{N} queens. Assuming that both of the players play perfectly your task is to determine who will win this game. \InputFile First line of the input contains \textbf{T} the number of test cases. Each test case starts with a line containing \textbf{3} integers \textbf{R} (\textbf{1} ≤ \textbf{R} ≤ \textbf{25}), \textbf{C} (\textbf{1} ≤ \textbf{C} ≤ \textbf{10^15}) and \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{1000}). Each of the next \textbf{N} lines contains the positions of \textbf{N} queens. The position is denoted by two integers. The first integer is the row number and the second integer is the column numbers. \OutputFile For each test case output "\textbf{YES}" if the first player has a winning strategy and "\textbf{NO}" otherwise. Look at the output for sample input for details.
Zaman məhdudiyyəti 2 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
3
5 5 1
2 3
5 5 2
4 4
4 4
5 5 3
1 2
2 1
2 2
Çıxış verilənləri #1
NO
NO
YES
Mənbə ACM-ICPC Asia Phuket Regional Programming Contest - 4 November 2011 – PSU, Phuket Campus