CF896B.Ithea Plays With Chtholly

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

This is an interactive problem. Refer to the Interaction section below for better understanding.

Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight.

Initially, Ithea puts nn clear sheets of paper in a line. They are numbered from 11 to nn from left to right.

This game will go on for mm rounds. In each round, Ithea will give Chtholly an integer between 11 and cc , and Chtholly needs to choose one of the sheets to write down this number (if there is already a number before, she will erase the original one and replace it with the new one).

Chtholly wins if, at any time, all the sheets are filled with a number and the nn numbers are in non-decreasing order looking from left to right from sheet 11 to sheet nn , and if after mm rounds she still doesn't win, she loses the game.

Chtholly really wants to win the game as she wants to cook something for Willem. But she doesn't know how to win the game. So Chtholly finds you, and your task is to write a program to receive numbers that Ithea gives Chtholly and help her make the decision on which sheet of paper write this number.

输入格式

The first line contains 3 integers n,mn,m and cc (, means rounded up) — the number of sheets, the number of rounds and the largest possible number Ithea can give to Chtholly respectively. The remaining parts of input are given throughout the interaction process.

输出格式

In each round, your program needs to read one line containing a single integer pip_{i} ( 1<=pi<=c1<=p_{i}<=c ), indicating the number given to Chtholly.

Your program should then output a line containing an integer between 11 and nn , indicating the number of sheet to write down this number in.

After outputting each line, don't forget to flush the output. For example:

  • fflush(stdout) in C/C++;
  • System.out.flush() in Java;
  • sys.stdout.flush() in Python;
  • flush(output) in Pascal;
  • See the documentation for other languages.

If Chtholly wins at the end of a round, no more input will become available and your program should terminate normally. It can be shown that under the constraints, it's always possible for Chtholly to win the game.

输入输出样例

  • 输入#1

    2 4 4
    2
    1
    3
    

    输出#1

    1
    2
    2
    

说明/提示

In the example, Chtholly initially knew there were 22 sheets, 44 rounds and each number was between 11 and 44 . She then received a 22 and decided to write it in the 11 st sheet. Then she received a 11 and wrote it in the 22 nd sheet. At last, she received a 33 and replaced 11 with 33 in the 22 nd sheet. At this time all the sheets were filled with a number and they were non-decreasing, so she won the game.

Note that it is required that your program terminate immediately after Chtholly wins and do not read numbers from the input for the remaining rounds. If not, undefined behaviour may arise and it won't be sure whether your program will be accepted or rejected. Also because of this, please be careful when hacking others' codes. In the sample, Chtholly won the game after the 33 rd round, so it is required that your program doesn't read the number of the remaining 44 th round.

The input format for hacking:

  • The first line contains 3 integers n,mn,m and cc ;
  • The following mm lines each contains an integer between 11 and cc , indicating the number given to Chtholly in each round.
首页