终判才知道自己失了智。本场据说是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. UVA 12161 Ironman Race in Treeland (树分治)

    题意:求树上的一条费用不超过m的路径,使得总长度尽量大. 人参第一发树分治,紫书上思路讲得比较清晰,这里不再赘述. 实现的时候,用一个类似时间戟的东西,记录结点首次访问的时间,并保存结点序列. 合并的 ...

  2. 【洛谷2257】YY的GCD(莫比乌斯反演)

    点此看题面 大致题意: 求\(\sum_{x=1}^N\sum_{y=1}^MIsPrime(gcd(x,y))\). 莫比乌斯反演 听说此题是莫比乌斯反演入门题? 一些定义 首先,我们可以定义\(f ...

  3. geoWithin查询 多边形查询

    $geoWithin查询 形状的表示 .$box:矩形,使用 {$box:[[<x1>,<y1>],[<x2>,<y2>]]}表示 都是坐标,第一个坐标 ...

  4. js 常用工具类

    /** * 存储sessionStorage */const setStore = (name, content) => { window.sessionStorage.setItem(name ...

  5. hadoop install

    1.home下建立hadoop 2.在Downloads下解压hadoop-2.6.0.tar.gz 3.将解压后的hadoop-2.6.0移动到/home/hadoop 4.csf@ubuntu:/ ...

  6. JS控制台的使用

    1.快捷键F12可直接进入控制台(或者单机右键->检查)用于bug调试 2.控制台如图: Elements:表示所有的js元素 Console:常用的有如下几个功能: ①console.log: ...

  7. 1048: [HAOI2007]分割矩阵

    Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1184  Solved: 863[Submit][Status][Discuss] Descripti ...

  8. 两个list缩进为一个list,python

    # w_list = ['a', 'b', 'c', 'd'] # e_list = ['c', 'd', 'b', 'a'] w_list = ['a', 'b', 'c', 'd', 'ff', ...

  9. php订单号的生成

    来自ECSHOP订单号生成函数:/includes/lib_order.php文件中的get_order_sn() /** * 得到新订单号 * @return string */ function ...

  10. ARM Linux内核源码剖析索引

    start_kernel -->asm-offset.h 生成 -->proc_info_list   -->machine_desc -->__vet_atags --> ...