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 ...
随机推荐
- ffmpeg —— 添加水印
1.添加水印——movie过滤器: ffmpeg -i inputfile -vf "movie=masklogo,scale= 60: 30[watermask]; [in] [wate ...
- linux 命令——13 less(转)
less 工 具也是对文件或其它输出进行分页显示的工具,应该说是linux正统查看文件内容的工具,功能极其强大.less 的用法比起 more 更加的有弹性. 在 more 的时候,我们并没有办法向前 ...
- xtrabackup 安装
xtrabackup 安装 yum install -y perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL perl-Dige ...
- ZOJ-1654 Place the Robots---二分图最小点覆盖+构图
题目链接: https://vjudge.net/problem/ZOJ-1654 题目大意: 有一个N*M(N,M<=50)的棋盘,棋盘的每一格是三种类型之一:空地.草地.墙.机器人只能放在空 ...
- fflush - 刷新一个流
SYNOPSIS 总览 #include <stdio.h> int fflush(FILE *stream); DESCRIPTION 描述 函数 fflush 强制在所给的输出流或更新 ...
- JSON对象转成formData对象,formData对象转成JSON对象
在向后端请求时,如果上传的数据里存在file文件对象,需要用到表单提交,这时候我们需要将JSON对象,转成formData对象,具体见代码 const formData = new FormData( ...
- yield 生成器的运行机制
yield 生成器的运行机制 当你问生成器要一个数时,生成器会执行,直至出现 yield 语句,生成器把 yield 的参数给你,之后生成器就不会往下继续运行. 当你问他要下一个数时,他会从上次的状态 ...
- softmax 函数
总结为: 将一组数变换为 总和为1,各个数为0~1之间的软性归一化结果. ========================================================= 关于 ...
- 把网上图片下载到本地的java工具类
package com.swift; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; ...
- 【算法】Fibonacci(斐波那契数列)相关问题
一.列出Fibonacci数列的前N个数 using System; using System.Collections.Generic; using System.Linq; using System ...