CF1470C.Strange Shuffle

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is an interactive problem.

nn people sitting in a circle are trying to shuffle a deck of cards. The players are numbered from 11 to nn, so that players ii and i+1i+1 are neighbours (as well as players 11 and nn). Each of them has exactly kk cards, where kk is even. The left neighbour of a player ii is player i−1i - 1, and their right neighbour is player i+1i + 1 (except for players 11 and nn, who are respective neighbours of each other).

Each turn the following happens: if a player has xx cards, they give ⌊x/2⌋\lfloor x / 2 \rfloor to their neighbour on the left and ⌈x/2⌉\lceil x / 2 \rceil cards to their neighbour on the right. This happens for all players simultaneously.

However, one player pp is the impostor and they just give all their cards to their neighbour on the right. You know the number of players nn and the number of cards kk each player has initially, but pp is unknown to you. Your task is to determine the value of pp, by asking questions like "how many cards does player qq have?" for an index qq of your choice. After each question all players will make exactly one move and give their cards to their neighbours. You need to find the impostor by asking no more than 10001000 questions.

这是一个交互式问题。

有 nn 个人围坐成一圈,正在尝试洗一副扑克牌。玩家编号为 11 到 nn,因此玩家 ii 和 i+1i+1 是相邻的(玩家 11 和 nn 也彼此相邻)。每人恰好持有 kk 张牌,其中 kk 为偶数。玩家 ii 的左邻是玩家 i−1i - 1,右邻是玩家 i+1i + 1(但玩家 11 和 nn 彼此互为左右邻)。

每一轮执行如下操作:若某玩家当前持有 xx 张牌,则其向左邻给出 ⌊x/2⌋\lfloor x / 2 \rfloor 张牌,向右邻给出 ⌈x/2⌉\lceil x / 2 \rceil 张牌。所有玩家同时进行此操作。

然而,其中一名玩家 pp 是“冒名者”(impostor),他/她会将自己全部的牌都交给右邻。你已知玩家总数 nn 及每人初始持牌数 kk,但冒名者 pp 的身份未知。你的任务是通过提问来确定 pp 的值;每次提问的形式为:“玩家 qq 当前有多少张牌?”,其中 qq 由你指定。每次提问后,所有玩家将恰好执行一轮操作(即按上述规则分发牌)。你至多只能提出 10001000 个问题,就必须找出冒名者。

输入格式

The first line contains two integers nn and kk (4≤n≤1054 \le n \le 10^5, 2≤k≤1092 \le k \le 10^9, kk is even) — the number of players and the number of cards.

第一行包含两个整数 nn 和 kk(4≤n≤1054 \le n \le 10^5,2≤k≤1092 \le k \le 10^9,且 kk 为偶数)—— 分别表示玩家数量和卡片总数。

输入输出样例

  • 输入#1

    4 2
    
    2
    
    1
    
    2
    
    3
    
    2

    输出#1

    ? 1
    
    ? 1
    
    ? 2
    
    ? 3
    
    ? 4
    
    ! 2

说明/提示

In the example the cards are transferred in the following way:

  • 22 22 22 22 — player 11 has 22 cards.
  • 11 22 33 22 — player 11 has 11 card.

After this turn the number of cards remains unchanged for each player.

在示例中,卡片按以下方式转移:

  • 22 22 22 22 — 玩家 11 拥有 22 张卡片。
  • 11 22 33 22 — 玩家 11 拥有 11 张卡片。

在此轮之后,每位玩家所持卡片数量保持不变。

输入解题思路,AI测评打分。不知道怎么写?

首页