题目链接

交互题。

题意:给你三个数n,m,k.让你完成至多m次互动,每次给你一个q,让你从n个位置选一个位置放这个数,覆盖已经放过的数。让你再m次使得n个位置的数不递减,达到直接退出。

解法:暴力,如果q小于c/2的话,从前往后找,若当前位置没有数或者比q大的话,就直接放再这个位置上,大于c/2的话就从后往前找,若当前位置没有数或者比q小的话就直接放。

如果每个位置都有数的话说明放完了。

#include<bits/stdc++.h>

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back using namespace std; LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
int ans[20093];
int main(){
ios::sync_with_stdio(false);
int n,m,c;
cin>>n>>m>>c;
for(int i=1;i<=m;i++){
int q;
int ke=0;
for(int j=1;j<=n;j++){
if(!ans[j]){ke=1;break;}
}
if(!ke)break;
cin>>q;
ans[n+1]=2e9;
if(q<=c/2){
int bj=0;
for(int j=1;j<=n;j++){
if(ans[j]==0||ans[j]>q){
ans[j]=q;
cout<<j<<endl;
bj=1;
break;
}
}
if(!bj){ans[n]=q;cout<<1<<endl;}
}else{
int bj=0;
for(int j=n;j>=1;j--){
if(ans[j]==0||ans[j]<q){
ans[j]=q;
bj=1;
cout<<j<<endl;
break;
}
}
if(!bj){ans[1]=q;cout<<1<<endl;}
}
fflush(stdout);
}
return 0;
}

Codeforces Round #449 (Div. 2) D. Ithea Plays With Chtholly的更多相关文章

  1. Codeforces Round #449 (Div. 2)

    Codeforces Round #449 (Div. 2) https://codeforces.com/contest/897 A #include<bits/stdc++.h> us ...

  2. Codeforces Round #449 (Div. 2)ABCD

    又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...

  3. Codeforces Round #449 (Div. 2) B. Chtholly's request【偶数位回文数】

    B. Chtholly's request time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  4. Codeforces Round #449 (Div. 2)-897A.Scarborough Fair(字符替换水题) 897B.Chtholly's request(处理前一半) 897C.Nephren gives a riddle(递归)

    A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #449 Div. 1

    B:注意到nc/2<=m,于是以c/2为界决定数放在左边还是右边,保证序列满足性质的前提下替换掉一个数使得其更靠近边界即可. #include<iostream> #include& ...

  6. Codeforces Round #449 (Div. 1) Willem, Chtholly and Seniorious (ODT维护)

    题意 给你一个长为 \(n\) 的序列 \(a_i\) 需要支持四个操作. \(1~l~r~x:\) 把 \(i \in [l, r]\) 的 \(a_i\) 加 \(x\) . \(2~l~r~x: ...

  7. Codeforces Round #449 (Div. 1)C - Willem, Chtholly and Seniorious

    ODT(主要特征就是推平一段区间) 其实就是用set来维护三元组,因为数据随机所以可以证明复杂度不超过O(NlogN),其他的都是暴力维护 主要操作是split,把区间分成两个,用lowerbound ...

  8. Codeforces Round #449 (Div. 2) C. DFS

    C. Nephren gives a riddle time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  9. Codeforces Round #449 (Div. 2) A. Scarborough Fair【多次区间修改字符串】

    A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. Linux下配置nfs并远程挂载实战探讨

    简单介绍: nfs是网络文件系统,允许一个节点通过网络访问远程计算机的文件系统,远程文件系统可以被直接挂载到本地,文件操作和本地没有区别,如果是局域网的nfs那么io的性能也可以保证 nfs是Netw ...

  2. 报错:[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop bei

    项目中遇到父组件传值 activeIndex <Tabs :tabs="tabs" :activeIndex="activeIndex" >< ...

  3. CMD 和 Git 中的代理设置

    CMD 设置代理 在 cmd 环境下设置代理可能不是很常用,但是某些情况下还是可能会用到,比如公司的电脑只能通过设置代理访问外网,而你需要在 cmd 环境下使用 gem 命令更新文件时. 当然,如果你 ...

  4. Linux-基础学习(六)-Redis的进阶学习

    1. redis的进阶操作 1.1 redis的订阅操作 发布订阅的命令 PUBLISH channel msg 将信息 message 发送到指定的频道 channel SUBSCRIBE chan ...

  5. matlab读取cvs文件的几种方法

    matlab读取CVS文件的几种方法: 1,实用csvread()函数   csvread()函数有三种使用方法: 1.M = csvread('filename')2.M = csvread('fi ...

  6. 数据采集工具Telegraf:简介及安装

    接着上一篇博客:InfluxDB简介及安装,这篇博客介绍下Linux环境下Telegraf安装以及其功能特点... 官网地址:influxdata 官方文档:telegraf文档 环境:CentOS7 ...

  7. HashMap 与 Hashtable 的区别

    Hashtable t 小写 二者用法一致   都实现Map接口 1.HashMap 的键值可以为null,而Hashtable不允许("null" 不是 null 前者是字符串 ...

  8. Crypto加密解密

    crypto 模块提供了加密功能,包含对 OpenSSL 的哈希.HMAC.加密.解密.签名.以及验证功能的一整套封装.我们这里讲crypto AES算法加密 一.使用步骤 1.引入Crypto 1. ...

  9. 微信小程序手机预览请求不到数据(最后一条不明所以)

    本地开发调试小程序时,用手机预览需要有如下设置:1.微信开发者工具中设置:不校验安全域名.web-view 域名.TLS 版本以及 HTTPS 证书.这样在有网络请求的时候,就可以访问本地的服务器了, ...

  10. 跨域下使用获取iframe的父页面URL

    通常情况下,我们获取iframe父页面的url很简单:parent.location或top.location即可,但前提是它们遵循同源策略. 当iframe与父页面不属于同一个域名时,像上面的获取会 ...