CF1205C.Palindromic Paths
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem
You are given a grid n×n, where n is odd. Rows are enumerated from 1 to n from up to down, columns are enumerated from 1 to n from left to right. Cell, standing on the intersection of row x and column y, is denoted by (x,y).
Every cell contains 0 or 1. It is known that the top-left cell contains 1, and the bottom-right cell contains 0.
We want to know numbers in all cells of the grid. To do so we can ask the following questions:
"? x1 y1 x2 y2", where 1≤x1≤x2≤n, 1≤y1≤y2≤n, and x1+y1+2≤x2+y2. In other words, we output two different cells (x1,y1), (x2,y2) of the grid such that we can get from the first to the second by moving only to the right and down, and they aren't adjacent.
As a response to such question you will be told if there exists a path between (x1,y1) and (x2,y2), going only to the right or down, numbers in cells of which form a palindrome.
For example, paths, shown in green, are palindromic, so answer for "? 1 1 2 3" and "? 1 2 3 3" would be that there exists such path. However, there is no palindromic path between (1,1) and (3,1).

Determine all cells of the grid by asking not more than n2 questions. It can be shown that the answer always exists.
这是一个交互式问题。
给定一个 n×n 的网格,其中 n 为奇数。行从上到下编号为 1 到 n,列从左到右编号为 1 到 n。位于第 x 行、第 y 列的格子记作 (x,y)。
每个格子中包含数字 0 或 1。已知左上角格子 (1,1) 中为 1,右下角格子 (n,n) 中为 0。
我们的目标是确定网格中所有格子内的数字。为此,你可以提出如下形式的问题:
“? x1 y1 x2 y2”,其中 1≤x1≤x2≤n,1≤y1≤y2≤n,且满足 x1+y1+2≤x2+y2。换言之,你输出网格中两个不同的格子 (x1,y1) 和 (x2,y2),使得仅通过向右或向下移动即可从第一个格子到达第二个格子,且这两个格子不相邻。
对于该问题,系统将返回:是否存在一条仅向右或向下移动、连接 (x1,y1) 与 (x2,y2) 的路径,使得该路径上所有格子中的数字构成一个回文串。
例如,图中以绿色标出的路径均为回文路径,因此对问题 “? 1 1 2 3” 和 “? 1 2 3 3” 的回答均为“存在这样的路径”。然而,在 (1,1) 与 (3,1) 之间并不存在回文路径。

请通过不超过 n2 次提问,确定网格中所有格子的数值。可以证明答案恒存在。
输入格式
The first line contains odd integer (3≤n<50) — the side of the grid.
第一行包含一个奇数整数(3≤n<50)——网格的边长。
输入输出样例
输入#1
3 0 1 0 1 1 1 1
输出#1
? 1 1 1 3 ? 1 1 2 3 ? 2 1 2 3 ? 3 1 3 3 ? 2 2 3 3 ? 1 2 3 2 ? 1 2 3 3 ! 100 001 000
输入解题思路,AI测评打分。不知道怎么写?