CF1100D.Dasha and Chess
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive task.
Dasha and NN like playing chess. While playing a match they decided that normal chess isn't interesting enough for them, so they invented a game described below.
There are 666 black rooks and 1 white king on the chess board of size 999×999. The white king wins if he gets checked by rook, or, in other words, if he moves onto the square which shares either a row or column with a black rook.
The sides take turns, starting with white. NN plays as a white king and on each of his turns he moves a king to one of the squares that are adjacent to his current position either by side or diagonally, or, formally, if the king was on the square (x,y), it can move to the square (nx,ny) if and only max(∣nx−x∣,∣ny−y∣)=1 , 1≤nx,ny≤999. NN is also forbidden from moving onto the squares occupied with black rooks, however, he can move onto the same row or column as a black rook.
Dasha, however, neglects playing by the chess rules, and instead of moving rooks normally she moves one of her rooks on any space devoid of other chess pieces. It is also possible that the rook would move onto the same square it was before and the position wouldn't change. However, she can't move the rook on the same row or column with the king.
Each player makes 2000 turns, if the white king wasn't checked by a black rook during those turns, black wins.
NN doesn't like losing, but thinks the task is too difficult for him, so he asks you to write a program that will always win playing for the white king. Note that Dasha can see your king and play depending on its position.
这是一个交互式题目。
达莎(Dasha)和 NN 喜欢下国际象棋。在一次对局中,他们觉得标准的国际象棋不够有趣,于是发明了如下游戏。
棋盘大小为 999×999,上面放置了 666 个黑车(rook)和 1 个白王(king)。若白王被车将死(即白王移动至与某个黑车处于同一行或同一列的格子上),则白王获胜。
双方轮流行动,白方先行。NN 扮演白王,每回合他可将王移动到与其当前位置相邻(包括横向、纵向或斜向)的任意一个格子上;形式化地说,若王当前位于 (x,y),则它可移动至 (nx,ny) 当且仅当 max(∣nx−x∣,∣ny−y∣)=1,且 1≤nx,ny≤999。NN 不得将王移至已有黑车占据的格子上;但他可以将王移至与某个黑车同行或同列的格子(只要该格子本身未被黑车占据)。
然而,达莎并不遵守国际象棋规则:她不按常规方式移动车,而是每次选择一个黑车,将其移动到任意一个未被其他棋子占据的空格上。她甚至可以将车移动到它原本所在的格子上(此时局面不变)。但有一个限制:她不能将车移动到与白王同行或同列的格子上。
每位玩家各进行 2000 回合;若在这总共 4000 回合内,白王始终未被黑车将死,则黑方获胜。
NN 不喜欢输,但又觉得这个任务对他而言太难,因此请你编写一个程序,使其在扮演白王时总能获胜。注意:达莎能看到你的白王位置,并会据此动态调整她的策略。
输入格式
In the beginning your program will receive 667 lines from input. Each line contains two integers x and y (1≤x,y≤999) — the piece's coordinates. The first line contains the coordinates of the king and the next 666 contain the coordinates of the rooks. The first coordinate denotes the number of the row where the piece is located, the second denotes the column. It is guaranteed that initially the king isn't in check and that all pieces occupy different squares.
程序开始时将从输入中接收 667 行数据。每行包含两个整数 x 和 y(1≤x,y≤999),表示棋子的坐标。第一行是国王的坐标,接下来的 666 行是车的坐标。第一个坐标表示棋子所在的行号,第二个坐标表示列号。保证初始状态下国王未被将军,且所有棋子均位于不同的方格上。
输出格式
After getting king checked, you program should terminate immediately without printing anything extra.
在国王被将死之后,你的程序应立即终止,且不输出任何额外内容。
输入输出样例
输入#1
999 999 1 1 1 2 2 1 2 2 1 3 2 3 <...> 26 13 26 14 26 15 26 16 1 700 800 2 1 2 <...> -1 -1 -1
输出#1
999 998 999 997 <...> 999 26
说明/提示
The example is trimmed. The full initial positions of the rooks in the first test are available at https://pastebin.com/qQCTXgKP. It is not guaranteed that they will behave as in the example.
示例已被裁剪。第一个测试用例中车的完整初始位置可在 https://pastebin.com/qQCTXgKP 查看。不能保证它们的行为与示例中一致。
输入解题思路,AI测评打分。不知道怎么写?