Ithea Plays With Chtholly (模拟)

Codeforces 896B Ithea Plays With Chtholly 交互/构造 题意有一个长度为n的数组和m次操作并给出一个正整数c。每次操作会给出一个数x,保证x为不大于c的正整数。要求你每次都把x放到数组的某个空位置或替代掉某个数。使得在m次操作结束之前满足数组的每个位置都有数且其单调不降。注意必须在线,也就是在输入下一个数之前就要输出当前数所放的位置且不能再更改。分析有点意思的脑洞题(其实并不难),在比赛快结束的时候才想到。不然估计就要掉回div2了。 就是设mid=c 阅读详情

Ithea Plays With Chtholly

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 n clear sheets of paper in a line. They are numbered from 1 to n from left to right.

This game will go on for m rounds. In each round, Ithea will give Chtholly an integer between 1 and c, 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 n numbers are in non-decreasing order looking from left to right from sheet 1 to sheet n, and if after m 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.


Input

The first line contains 3 integers n, m and c (, 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.

Interaction

In each round, your program needs to read one line containing a single integer pi (1 ≤ pi ≤ c), indicating the number given to Chtholly.

Your program should then output a line containing an integer between 1 and n, 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.

Example
Input
2 4 4
2
1
3
Output
1
2
2
Note

In the example, Chtholly initially knew there were 2 sheets, 4 rounds and each number was between 1 and 4. She then received a 2 and decided to write it in the 1st sheet. Then she received a 1 and wrote it in the 2nd sheet. At last, she received a 3 and replaced 1 with 3 in the 2nd 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 3rd round, so it is required that your program doesn't read the number of the remaining 4th round.

The input format for hacking:

  • The first line contains 3 integers n, m and c;
  • The following m lines each contains an integer between 1 and c, indicating the number given to Chtholly in each round.

如果给的数小于等于c/2正着遍历板子,如果找到有大于这个数的替换否则到空位置放上,如果给的数大于c/2,倒着遍历板子

如果找到小于这个数的板子替换,否则找到第一个空板子放上。每次检查n个板子是否满了

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n,m,c;
int sheet[1002];
int main(){
    scanf("%d%d%d",&n,&m,&c);
    while(m--){
        int x;
        scanf("%d",&x);
        int cnt = 0;
        if(x * 2 <= c){
            for(int i = 1; i <= n; i++){
                if(sheet[i] > x){
                    sheet[i] = x;
                    printf("%d\n",i);
                    break;
                }
                if(!sheet[i]){
                    sheet[i] = x;
                    cnt++;
                    printf("%d\n",i);
                    break;
                }
            }
        }
        else{
            for(int i = n; i >= 1; i--){
                if(sheet[i] < x){
                    sheet[i] = x;
                    printf("%d\n",i);
                    break;
                }
                if(!sheet[i]){
                    sheet[i] = x;
                    cnt++;
                    printf("%d\n",i);
                    break;
                }
            }
        }

        fflush(stdout);
        if(cnt == n) break;
    }
    return 0;
}

FortiGate-60E防火墙忘记密码?用Console线+TFTP重装固件v7.0.9全流程 本文详细介绍了当FortiGate-60E防火墙忘记密码且物理重置无效时,如何通过Console线连接并利用TFTP服务器重装固件(如v7.0.9)的全流程。从恢复原理、工具准备、网络配置到逐步执行命令,提供了完整的实战指南,帮助管理员彻底恢复设备出厂设置并重置密码。 阅读详情

相关推荐

【项目案例】前后端分离项目 【Web图书管理系统 】SpringBoot + Vue + Element UI + Mysql

Web图书管理系统

激流丶的博客 5396

致——世界上最幸福的女孩——Chtholly

世界上最幸福的女孩——Chtholly

白夕の旅途 8877

Cadence Allegro16.6怎么导出器件引脚信息的报告

当我们需要用到器件的引脚相关信息时,可以利用allegro中的reports这个功能导出器件的相关信息。下面是具体的操作步骤。

suyucheng66的博客 5728

浅谈珂朵莉树(Chtholly Tree)——暴力而玄学的数据结构

关于它很珂学的名字… 珂朵莉树(Chtholly Tree),又称老司机树(Old Driver Tree),起源于CodeFoeces平台上编号为896C的一道题—— “ Willem, Chtholly and Seniorious ” (珂学家们此时不用翻译也知道这个名字是在说啥了) ,一位用户Old Driver在给出了线段树的正解之后,又发布了YY多年的 一份前所未有的玄学解法,其中利用......

CC_dsm的博客 2万+

告别理论!手把手教你用Patran/Nastran搞定机翼颤振分析(附完整模型文件)

本文提供了一份详细的机翼颤振分析实战指南,使用Patran/Nastran软件从零开始构建完整分析模型。涵盖几何建模、网格划分、模态分析到气动弹性耦合的全流程,特别适合航空航天领域工程师学习颤振分析技术。教程包含完整模型文件和实用脚本,帮助读者快速掌握这一关键飞行器设计技能。

weixin_30879169的博客 539

GEE——土地利用分类之监督分类

利用GEE做监督分类,以武汉市为例。 训练器我们选择随机森林;数据选择Landsat-8;训练样本使用的是GEE提供的一种,它把地表分为三类:水体、植被和城市用地。 选择训练样本 用要素集来标记训练样本。每个要素都有一个landcover 的属性,0表示城市用地,1表示植被,2表示水体。 对影像进行分类 其中一部分进行分类器的训练,还有一部分留下来做精度验证。 输出影像及混淆矩阵 print(LABEL_DATA); var wuhan = ee.FeatureCollection('users/

qq_41600680的博客 1万+

Interactive Problems(交互式问题) 2016.6.9

1、CodeForces_101021A Guess the Number #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned

追风蹑影 1616

基于STM32F103的智能门禁门锁门卫系统设计

本文设计了一种基于STM32F103单片机的智能门禁系统,集成了密码、射频IC卡和指纹识别三种验证方式。系统采用模块化设计,包含MFRC522射频模块、AS608指纹模块、矩阵键盘、OLED显示和舵机控制等硬件,实现了身份验证、密码修改、IC卡/指纹管理以及安全防护功能。测试结果表明系统响应迅速(密码验证250ms、指纹验证600ms)、功耗低(待机50mA),且具备掉电密码保存功能。该系统操作简便、功能完善,适用于家庭和办公场所,具有较高实用价值。未来可扩展远程控制、人脸识别等功能以进一步提升智能化水平。

3254968421的博客 317

【CodeForces - 897D】Ithea Plays With Chtholly (交互题型,贪心,思维构造,题目信息)

题目大意: 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. ...

xuanweiace的博客 656

手把手教你学simulink(8.39)--基于Simulink的步进电机(Stepper Motor)仿真实例

通过这个仿真实例,你可以学习如何使用Simulink构建和仿真步进电机(Stepper Motor)系统。你可以根据实际需求调整模型和参数,进行更复杂的仿真和分析。希望这个例子对你有所帮助,祝你学习愉快!

MHD0815的博客 1051

气象大模型光伏功率预测中的应用:从短期,超短期,中长期的实现与开源代码详解

本文详细介绍了基于大模型的光伏功率预测方法,涵盖超短期(15分钟-1小时)、短期(1-6小时)和中长期(1天-1周)预测。文章首先讨论了数据准备与预处理,包括历史功率、气象、天文和电站特性数据的收集与特征工程。随后,针对不同预测需求,提出了多种深度学习模型:超短期预测采用1DCNN-LSTM混合模型,短期预测使用Transformer模型,中长期预测则通过多尺度特征提取模型和概率预测方法处理不确定性。文章还提供了模型训练、评估、部署和优化的完整流程,并开源了代码实现。未来研究方向包括结合数值天气预报、开发时

专注AI大模型,软件混淆,授权 1569

Codeforces Round #703 (Div. 2) C interactive problem

这场div2被这个交互题打的头皮发麻。 20分钟我AC了AB两题,那是觉得这场要飞天,但开到C题的时候就懵逼了,题目是什么意思?输入是什么意思?输出又是什么鬼?%%%%% 因为这是本蒟蒻第一次写交互题,所以写这种题需要注意的点我完全不知道,于是乎出现了这个诡异的一幕:其他人拼命输出,而我却在学习what is interactive problem? 废话不多说,直接上题。 题目如下: 注释: 交互题,顾名思义就是一种通过不断给出信息,然后通过程序利用信息,最后得到答案的过程。 其不同于传统的题目,这种

weixin_50547586的博客 429

python+playwright 学习-10.pytest-playwright插件编写测试用例

pytest-playwright插件完美的继承了pytest 用例框架和playwright基础使用的封装,基本能满足工作中的常规需求了,不需要我们再做额外的插件开发。

qq_27371025的博客 2509

Ithea Plays With Chtholly

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,...

Sirius_han的博客 288

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Codeforces 897D. Ithea Plays With Chtholly (交互)

题目链接:D. Ithea Plays With Chtholly 题意:   给你n张纸,在纸上写字(在 1 - c之间)可以写m次数(,)。(主要是交互,让你判断) 题解:   首先,看到m>=n*c/2,我们假设从1位置放入数据,如果放入的数据大于前面已经放入的数据那就往后排小于就替换。这样放的话,每个位置替换最大的次数是C,所以最大的次数总数是n*c。发现正好差了...

225

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

CodeForce896 B. Ithea Plays With Chtholly

#include using namespace std; const int maxn = 1050 ; int n , m , c , temp ; int arr[maxn] ; int main(){ int num = 0 ; scanf("%d %d %d" , &n , &m , &c) ; memset(arr , -1 , sizeof(arr))

Samaritan_infi的博客 489

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

[Easy] CodeForces - 897D Ithea Plays With Chtholly | 贪心博弈

Codeforces 897D

PurityFan's 658

codeforces 897 D Ithea Plays With Chtholly(交互)

题意: 每次给你一个数,让你放到一个长度为n 的数组里,直到这个数组填满并且是不递减函数为止。需要 在m步内完成 c是给出的数的范围。 解题思路: 一种显然的暴力方法就是从1开始扫描,遇到第一个大于x的或是a[i]==0的就放。 但是还有显然的卡掉这种暴力的做法,就是把数n-1逐个给出,就每次要替换,这样的话就需要n^2次,显然不行。 所以应该能想到从两边,开始扫描,让大于c...

johsnows的博客 676

codeforces897 D Ithea Plays With Chtholly【贪心 + 交互题】

交互输入题 给你 n m c 代表有n张白纸,编号1-n, 系统会给你m次以内 得询问 每次给你一个[1 , c]的数字 你可以将这个数字填在某张纸上 如果该纸上有写数字了 你可以对其进行更改 要你打印出 每一次系统给的数字你是填在的纸的编号 请问如何填能够在 所有纸被填满的那一刻 让纸上的数字沿着编号非递减 题解: 有 m的取值范围 为 c/2 * n 所以每张纸最多都可以...

OOOak 531

Codeforces D - Ithea Plays With Chtholly

D - Ithea Plays With Chtholly 思路:考虑每个位置最多被替换c/2次 那么折半考虑,如果小于c/2,从左往右替换,大于c/2总右往左替换,只有小于这个数(从左往右)或者大于这个数(从右往左)才会被替换,所以每个位置最多被替换c/2次。 代码: #include<bits/stdc++.h> using namespace std; #def...

weixin_33712987的博客 156

codeforces 897D - Ithea Plays With Chtholly

D. Ithea Plays With Chtholly time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output This is an interactive problem. Refer to the Interaction secti

樱花满地集于我心,楪舞纷飞祈愿相随 1291

CodeForce 897 D. Ithea Plays With Chtholly

D. Ithea Plays With Chtholly time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This is an interactive problem.

DlPF_C的博客 477

【CodeForces】896 B. Ithea Plays With Chtholly

【题目】B. Ithea Plays With Chtholly 【题意】交互题,有n格,每次给一个[1,c]的数字,回答填入的位置后再次给数字,要求在m轮内使n格填满且数列不递减。n,m>=2,1<=c<=1000,1<=n*[c/2]<=m<=1000。 【算法】贪心 【题解】对于每次的数字x,找到第一个严格大于的位置替换之(或占一个新的空位置)。 ...

weixin_33895604的博客 101

题解 | 【CF896B】 Ithea Plays With Chtholly

题目链接:Here 给 \(m\) 个数,放到 \(1→n\) 一个位置上,若 \(1→n\) 都被填满且不下降就胜。强制在线。 看到题忽然觉得是水题,这不就最长不下降子序列的那个吗!直接上个二分就准备交了。 事实证明头铁了(怎么可能这么简单,2000分啊!) 反例: 15 5 9 29 1 8 1 7 若一个从前往后一个从后往前就可以完成,而那个做法还只填了 1 1 7 呢! 问题出在哪...

橘嘉禾 105

codeforces 896 B. Ithea Plays With Chtholly(构造||贪心)

http://codeforces.com/contest/896/problem/B 题意:交互题,有n格,每次给一个[1,c]的数字,回答填入的位置后再次给数字,要求在m轮内使n格填满且数列不递减。n,m>=2,1<=c<=1000,1<=n*[c/2]<=m<=1000。 思路:看到题目,我首先思考给出m>=nc/2 有什么用,一定能构造出序列,那么...

- 回忆゛ 267
上一篇: Goldbach`s Conjecture LightOJ - 1259(筛素数)
下一篇: Dream City ZOJ - 3211 (贪心+dp)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值