终判才知道自己失了智。本场据说是chinese专场,可是请允许我吐槽一下题意!

A. An abandoned sentiment from past

shabi贪心手残for循环边界写错了竟然还过了初判。回宿舍想想发现只要k大于1,可以直接输出Yes的。

const int N=1e6+5;
int a[N],b[N];
//char s[N];
int cmp(int a,int b)
{
return a>b;
}
int main()
{
int n,k;
while(~scanf("%d%d",&n,&k))
{
int num=0;
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);
if(!a[i]) num++;
}
for(int i=0; i<k; i++) scanf("%d",&b[i]);
sort(b,b+k,cmp);
int f=0,j=0;
for(int i=0; i<n; i++) if(a[i]==0&&j<k) a[i]=b[j++];
for(int i=1; i<n; i++) if(a[i]<=a[i-1]) f=1;
if(f) puts("Yes");
else puts("No");
}
return 0;
}

B.
An express train to reveries

被题意坑了一发,然而终判还是跪了。

根据题意:题目保证有解,结合样例只能有一组或者两组不同。一组的话随便输出一个没有出现过的数,注意范围。而两组的话可以直接暴力四种情况暴力判。比赛时却纠结怎么写,石乐志。关键在与证明最多只有两组不同。

int judge()
{
cls(vis,0);
for(int i=1;i<=n;i++)
{
if(vis[c[i]]) return 0;
vis[c[i]]++;
}
return 1;
}
int main()
{
while(~scanf("%d",&n))
{
cls(vis,0);
int num=0;//不同对的数量;
for(int i=1; i<=n; i++)
{
scanf("%d",&a[i]);
vis[a[i]]=1;
}
for(int i=1; i<=n; i++)
{
scanf("%d",&b[i]);
vis[b[i]]=1;
if(a[i]!=b[i]) num++;
}
if(num==1)
{
for(int i=1; i<=n; i++)
if(a[i]!=b[i])
{
for(int j=1; j<=n; j++)
if(!vis[j])
{
printf("%d ",j);
break;
}
}
else printf("%d ",a[i]);
}
else
{
int pos1=0,pos2=0;
for(int i=1; i<=n; i++)
{
if(a[i]==b[i]) c[i]=a[i];
else
{
if(!pos1) pos1=i;
else pos2=i;
}
}
c[pos1]=a[pos1],c[pos2]=a[pos2];
if(!judge())
{
c[pos1]=a[pos1],c[pos2]=b[pos2];
if(!judge())
{
c[pos1]=b[pos1],c[pos2]=a[pos2];
if(!judge())
c[pos1]=b[pos1],c[pos2]=b[pos2];
}
}
for(int i=1; i<=n; i++) printf("%d ",c[i]);
} puts("");
}
return 0;
}
//4
//3 2 1 3
//4 2 1 2

C.
An impassioned circulation of affection

全场唯一过的一道题。6e8在CF2s能过(手动滑稽

一个shabi滑动窗,结合样例猜了一发发现比B题还好写,结果又是细节上bug了半天,怎么办,我好像石乐志。。

const int N=1500+5;
int a[N][26];
char s[N];
int main()
{
int n,q;
while(~scanf("%d%s",&n,s+1))
{
memset(a,0,sizeof(a));
for(int i=1; i<=n; i++)
{
for(int j=0; j<26; j++) a[i][j]=a[i-1][j];
a[i][s[i]-'a']++;
}
scanf("%d",&q);
int k;
char str[5];
while(q--)
{
scanf("%d%s",&k,str);
int j=1,len=0;
int id=(str[0]-'a');
for(int i=1; i<=n; i++)
{
while(j<=n&&(j-i+1-(a[j][id]-a[i-1][id]))<=k) j++;
len=max(len,j-i);
}
printf("%d\n",len);
}
}
return 0;
}

怎么办,好久没写代码思维好像没有度假,但代码能力急剧下滑,怎么办,好慌。。。。

%一把Qls,当我做完B题时却发现QLS已经过了B题和D题。。。。不给弱鸡留活路啊。。

Codeforces Round #418 (Div. 2) A+B+C!的更多相关文章

  1. Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque

    Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque 题意: 给\(n(n <= 1000)\)个圆,圆与圆之间 ...

  2. Codeforces Round #418 (Div. 2).C two points

    C. An impassioned circulation of affection time limit per test 2 seconds memory limit per test 256 m ...

  3. Codeforces Round #418 (Div. 2)

    A: 不细心WA了好多次 题意:给你一个a序列,再给你个b序列,你需要用b序列中的数字去替换a序列中的0,如果能够替换,则需要判断a是否能构成一个非递增的序列,a,b中所有的数字不会重复 思路:就是一 ...

  4. Codeforces Round #418 (Div. 2) B. An express train to reveries

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  5. Codeforces Round #418 (Div. 2)D

    给n个圆要么包含,要么相分离,没有两个公共点,当成一棵树,把包含的面积大的放在上面 如图最上面的par记为-1,level记为0,当par==-1||level==1时就加否则减, 就是第一,二层先加 ...

  6. Codeforces Round #418 (Div. 2) C

    Description Nadeko's birthday is approaching! As she decorated the room for the party, a long garlan ...

  7. Codeforces Round #418 (Div. 2) B

    Description Sengoku still remembers the mysterious "colourful meteoroids" she discovered w ...

  8. Codeforces Round #418 (Div. 2) A

    Description A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight ...

  9. Codeforces Round #418 (Div. 2) C. An impassioned circulation of affection

    C. An impassioned circulation of affection time limit per test 2 seconds memory limit per test 256 m ...

随机推荐

  1. IOS 线程描述

    ●什么是线程 ● 1个进程要想执行任务,必须得有线程(每1个进程至少要有1条线程) ● 线程是进程的基本执行单元,一个进程(程序)的所有任务都在线程中执行 ● 比如使用酷狗播放音乐.使用迅雷下载电影, ...

  2. 一、Web 如何工作的

    平常我们在浏览器中输入一个网址,随即看到一个页面,这个过程是怎样实现的呢?下面用一幅图来说明: 整个流程如下: 1.域名解析  浏览器会解析域名对应的IP地址 PS:DNS服务器的知识 2.建立TCP ...

  3. 2018.10.03 NOIP+ 模拟赛 解题报告

    得分: \(30+5+0=35\)(考得真不咋滴) \(T1\):奥义商店(点此看题面) 以为很简单,对着这题想了一个多小时,最后果断打了个暴力交了... ... 看完题解发现其实也不是很难. 对于\ ...

  4. mongodb索引 全文索引

    全文索引,也叫文本索引,平时,我们百度的搜索,比如api文档的搜索,这种全局的索引就可以使用全文索引实现 全文索引:对字符串与字符串数组创建全文可搜索对索引 使用情况:比如有一个数据集合,存储了用户的 ...

  5. python基础一 day16 内置函数

    # 数据类型 :int bool ...# 数据结构 : dict list tuple set str reversed()l = [1,2,3,4,5]l.reverse()print(l)l = ...

  6. 洛谷P1220 关路灯【区间dp】

    题目:https://www.luogu.org/problemnew/show/P1220 题意:给定n盏灯的位置和功率,初始时站在第c盏处. 关灯不需要时间,走的速度是1单位/秒.问把所有的灯关掉 ...

  7. web项目小总结

     初步小结 1.之前的CSS有些遗忘,返回去重新看知识点,频繁会浪费项目时间. 比如说: position定位 1 position: absolute;//绝对定位 2 position:relat ...

  8. antd-design-pro 服务代理问题

    公司希望又一个后台管理页面.因为之前技术栈是react 所以选择了antd-design-pro作为后台的框架. 在连调api的时候,困惑怎么去代理.因为网上查到很多都是1.0的版本,而我现在用的是2 ...

  9. Linux运维企业架构项目实战系列

    Linux运维企业架构项目实战系列 项目实战1—LNMP的搭建.nginx的ssl加密.权限控制的实现 项目实战2—LVS.nginx实现负载均衡系列2.1 项目实战2.1—实现基于LVS负载均衡集群 ...

  10. Mysql数据库的权限、索引基本操作

    数据库的关闭方法: .优雅的关闭数据库的方法: mysqladmin -uroot -p123456 shutdown .脚本关闭: /etc/init.d/mysqld stop .使用kill信号 ...