Codeforces Round #418 (Div. 2) A+B+C!
终判才知道自己失了智。本场据说是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!的更多相关文章
- 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)\)个圆,圆与圆之间 ...
- 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 ...
- Codeforces Round #418 (Div. 2)
A: 不细心WA了好多次 题意:给你一个a序列,再给你个b序列,你需要用b序列中的数字去替换a序列中的0,如果能够替换,则需要判断a是否能构成一个非递增的序列,a,b中所有的数字不会重复 思路:就是一 ...
- 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 ...
- Codeforces Round #418 (Div. 2)D
给n个圆要么包含,要么相分离,没有两个公共点,当成一棵树,把包含的面积大的放在上面 如图最上面的par记为-1,level记为0,当par==-1||level==1时就加否则减, 就是第一,二层先加 ...
- Codeforces Round #418 (Div. 2) C
Description Nadeko's birthday is approaching! As she decorated the room for the party, a long garlan ...
- Codeforces Round #418 (Div. 2) B
Description Sengoku still remembers the mysterious "colourful meteoroids" she discovered w ...
- Codeforces Round #418 (Div. 2) A
Description A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight ...
- 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 ...
随机推荐
- POJ-1936 All in All---字符串水题
题目链接: https://vjudge.net/problem/POJ-1936 题目大意: 给两个字符串,判断是s1是不是s2的子序列 思路: 水 #include<iostream> ...
- NOIP2018赛前停课集训记——最后的刷板子计划
前言 再过两天就\(NOIP2018\)了. 于是,我决定不做其他题目,开始一心一意刷板子了. 这篇博客记录的就是我的刷板子计划. [洛谷3383][模板]线性筛素数 这种普及-的题目我还写挂了两次( ...
- 在RichTextBox控件中替换文本文字
实现效果: 知识运用: RichTextBox控件的SelectedText属性 实现代码: private void button1_Click(object sender, EventArgs e ...
- 使ListView控件中的选择项高亮显示
实现效果: 知识运用: ListView控件的SelectedItems属性 //获取在ListView控件中被选中数据项的集合 public ListView.SelectedListViewIte ...
- Problem I: Satellite Photographs
Problem I: Satellite Photographs Time Limit: 1 Sec Memory Limit: 128 MB Submit: 208 Solved: 118 [S ...
- python psutil 编译中断。 error: command 'gcc' failed with exit status 1
error info [root@chenbj psutil-2.0.0]# python setup.py install running install running bdist_egg run ...
- 前端安全之XSS和csrf攻击
1.Csrf攻击概念: csrf攻击(Cross-site request forgery):跨站请求伪造; 2.Csrf攻击原理: 用户是网站A的注册用户,且登录进去,于是网站A就给用户下发cook ...
- Cookie 与 Session 的区别
Cookie与Session的区别 cookie的简介 cookie是Web服务器保存在客户端的一系列文本信息 cookie的作用 对特定对象的追踪 统计网页浏览次数 简化登录 安全性能:容易信息泄露 ...
- java面向对象思想2
1.主函数是一类特殊的函数,作为程序入口,可被虚拟机调用.主函数格式是固定的.public:函数访问权限最大.static:代表函数随着类的加载已经存在.void:主函数没有具体返回值.main:不是 ...
- (79)zabbix key总是not supported的解决方法
zabbix定义好key之后,总是会出现Not supported,看到这个问题,大家不用着急,问题其实很容易解决,首先鼠标点击当前key的大红叉上,会显示出报错内容. 常见的有: 1. zabbix ...