Codeforces Round #449 (Div. 2) D. Ithea Plays With Chtholly
题目链接
交互题。
题意:给你三个数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的更多相关文章
- Codeforces Round #449 (Div. 2)
Codeforces Round #449 (Div. 2) https://codeforces.com/contest/897 A #include<bits/stdc++.h> us ...
- Codeforces Round #449 (Div. 2)ABCD
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...
- 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 ...
- 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 ...
- Codeforces Round #449 Div. 1
B:注意到nc/2<=m,于是以c/2为界决定数放在左边还是右边,保证序列满足性质的前提下替换掉一个数使得其更靠近边界即可. #include<iostream> #include& ...
- 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: ...
- Codeforces Round #449 (Div. 1)C - Willem, Chtholly and Seniorious
ODT(主要特征就是推平一段区间) 其实就是用set来维护三元组,因为数据随机所以可以证明复杂度不超过O(NlogN),其他的都是暴力维护 主要操作是split,把区间分成两个,用lowerbound ...
- 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 ...
- 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 ...
随机推荐
- nginx [alert] 12339#0: 1024 worker_connections are not enough
进一步分析报错原因,具体步骤如下: l 查看这两台系统最大的允许文件打开数 [root@nginx01 logs]# cat /proc/sys/fs/file-max 343927 l 通过ul ...
- 运行ConnectionDemo时遇到的问题及解决方案
20175227张雪莹 2018-2019-2 <Java程序设计> 运行ConnectionDemo时遇到的问题及解决方案 老师博客上提供确认数据库连接的代码 import static ...
- day19-网络编程基础(二)
今天没有很多概念性的东西,主要是方法性的东西以及编程的一些方法吧 今日份目录 1.UDP传输的特点以及实验 2.UTP与UDP传输的区别 3.基于tcp的low版带验证功能的FTP小程序 4.基于so ...
- linux 网卡的混杂模式的取消
1.Linux下网卡常用的几种模式说明: 广播方式:该模式下的网卡能够接收网络中的广播信息. 组播方式:设置在该模式下的网卡能够接收组播数据. 直接方式:在这种模式下,只有目的网卡才能接收该数据. 混 ...
- day 16 包的导入
包的认识 '''包通过文件夹来管理一系列功能相近的模块包:一系列模块的集合体重点:包中一定有一个专门用来管理包中所有模块的文件包名:存放一系列模块的文件夹名字包名(包对象)存放的是管理模块的那个文件 ...
- 【洛谷】【二分答案+最短路】P1462 通往奥格瑞玛的道路
在艾泽拉斯大陆上有一位名叫歪嘴哦的神奇术士,他是部落的中坚力量 有一天他醒来后发现自己居然到了联盟的主城暴风城 在被众多联盟的士兵攻击后,他决定逃回自己的家乡奥格瑞玛 题目背景 [题目描述:] 在艾泽 ...
- Leetcode 21. Merge Two Sorted Lists(easy)
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...
- mysq基础操作
创建表: create table customer(mid char(5) primary key,name varchar(20),birth date,sex char(1) DEFAULT ' ...
- ADO.NET之使用DataSet类更新数据库
1.首先从数据库获得数据填充到DataSet类,该类中的表和数据库中的表相互映射. 2.对DataSet类中的表进行修改(插入,更新,删除等) 3.同步到数据库中:使用SqlDataAdapter实例 ...
- js-模块化(三大模块化规范)
###1. JS模块化 * 模块化的理解 * 什么是模块? * 将一个复杂的程序依据一定的规则(规范)封装成几个块(文件), 并进行组合在一起 * 块的内部数据/实现是私有的, 只是向外部 ...