Codeforces Round #571 (Div. 2)

日常被tanao_大佬带飞,我AC了A和C(B题没了。。。否则tanao_大佬肯定把我吊打)

A. Vus the Cossack and a Contest

Vus the Cossack holds a programming competition, in which \(n\) people participate. He decided to award them all with pens and notebooks. It is known that Vus has exactly \(m\) pens and \(k\) notebooks.

Determine whether the Cossack can reward all participants, giving each of them at least one pen and at least one notebook.

Input

The first line contains three integers \(n\), \(m\), and \(k\) (1≤n,m,k≤100) — the number of participants, the number of pens, and the number of notebooks respectively.

Output

Print "Yes" if it possible to reward all the participants. Otherwise, print "No".

You can print each letter in any case (upper or lower).

Div.2的A标准打卡题难度,翻译:

给你整数n、m、k,判断m和k是否都大于等于n

这好像都比noip2018pj的t1都要简单。。。

直接if完事

Code:

#include <cstdio>
#include <cctype>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
s=0;
reg char c=getchar();
while(!isdigit(c))
c=getchar();
while(isdigit(c))
s=(s<<3)+(s<<1)+(c^48),c=getchar();
return;
}
signed main(void)
{
int n,m,k;
rd(n);rd(m);rd(k);
if(m>=n&&k>=n)
puts("Yes");
else
puts("No");
return 0;
}

C. Vus the Cossack and Strings

Vus the Cossack has two binary strings, that is, strings that consist only of "0" and "1". We call these strings a and b. It is known that |b|≤|a|, that is, the length of b is at most the length of a.

The Cossack considers every substring of length |b| in string a. Let's call this substring c. He matches the corresponding characters in b and c, after which he counts the number of positions where the two strings are different. We call this function f(b,c).

For example, let b=00110, and c=11000. In these strings, the first, second, third and fourth positions are different.

Vus the Cossack counts the number of such substrings c such that f(b,c) is even.

For example, let a=01100010 and b=00110. aa has four substrings of the length |b|: 01100, 11000, 10001, 00010.

  • f(00110,01100)=2;
  • f(00110,11000)=4;
  • f(00110,10001)=4;
  • f(00110,00010)=1.

Since in three substrings, f(b,c)f(b,c) is even, the answer is 33.

Vus can not find the answer for big strings. That is why he is asking you to help him.

Input

The first line contains a binary string a \((1≤|a|≤10^6)\) — the first string.

The second line contains a binary string b \((1≤|b|≤|a|)\) — the second string.

Output

Print one number — the answer.

input1

01100010
00110

output1

3

input2

1010111110
0110

output2

4

人话:

给你两个个二进制串a和b,b的长度小于等于a,将a的每个长度位b长度的连续子序列拿出来和a进行f操作,f操作就是比对两个串有几位不同,如果这个数是偶数,那么答案加一

样例1的解释在题面里有了

那么直接开始分析吧:

这个f操作一看就知道是异或然后统计1的个数,但是直接做或者bitset都会超时,那么

这题看到偶数就应该想到奇偶性,那么奇偶性与 和以及异或和 是有关的,于是。。。

把a串的前缀和求出来,再把b串的异或和求出来

然后看看,我们只要得知f结果的奇偶性就好了,并不要得知他是多少

所以,a的前缀和可以帮我们知道a的一段区间内和的奇偶性,我们也可以得知这段区间内1的出现次数的奇偶性

那么,b的异或和可以帮助我们知道b串中1的出现次数的奇偶性

那么,如果这两个奇偶性相同时,那么我们就得知他们异或后的结果内1的个数是偶数个

\(e.g.\):我们定义g函数为区间内1出现次数的奇偶性(1奇,0偶)

\(g(10101)=1\), \(g(10010)=0\), 所以它们异或后的结果1的个数一定为奇数个

检验:\(10101 xor 10010 = 00111\)

那么代码就有了,Code:

#include <cstdio>
#include <cctype>
#include <cstring>
#include <bitset>
#define reg register
using namespace std;
const int MaxN=1000001;
template <class t> inline void rd(t &s)
{
s=0;
reg char c=getchar();
while(!isdigit(c))
c=getchar();
while(isdigit(c))
s=(s<<3)+(s<<1)+(c^48),c=getchar();
return;
}
char ia[MaxN],ib[MaxN];
int a[MaxN],b[MaxN],f[MaxN],g[MaxN];
int lena,lenb;
signed main(void)
{
scanf("%s%s",ia+1,ib+1);
lena=strlen(ia+1),lenb=strlen(ib+1);
// printf("%d %d",lena,lenb);
for(int i=1;i<=lena;++i)
{
a[i]=(ia[i]=='1')?1:0;
f[i]=f[i-1]+a[i];
}
for(int i=1;i<=lenb;++i)
{
b[i]=(ib[i]=='1')?1:0;
g[i]=g[i-1]^b[i];
}
reg int ans=0,k,u;
for(int i=lenb;i<=lena;++i)
{
u=i-lenb+1;
k=(f[i]-f[u-1])&1;
k=!k;
ans+=k^g[lenb];
}
printf("%d",ans);
return 0;
}

D. Vus the Cossack and Numbers

关于D题,其实是我先开题的,结果我觉得C题可做,巨佬tanao_觉得D题可做,就换题了,我打了一份D的代码,结果马上被我叉了。。。这里不贴出来了,这里贴一下tanao_巨佬的代码

#include<iostream>
#include<cstdio>
using namespace std;
long long read()
{
long long x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
x=x*10+ch-'0',ch=getchar();
while(ch<'0'||ch>'9')
ch=getchar();
while(ch>='0'&&ch<='9')
x=x*10+ch-'0',ch=getchar();
return x*f;
}
long long c(long long x)
{
if(x%100000==0)
return x;
if(x<0)
return x-x%100000-100000;
return x-x%100000;
}
int main()
{
int n;
cin>>n;
long long sum=0;
for(int i=1;i<=n;++i)
{
long long x=read();
if(c(sum)+c(x)==c(sum+x))
cout<<c(x)/100000<<" ";
else
cout<<c(x)/100000+1<<" ";
sum+=x;
}
return 0;
}

我大概看了一下巨佬的代码,首先把浮点数乘以100000防止卡精度,然后?????,我写了主体70多行就被巨佬20多行解决了?

不过思路差不多,开一个sum用来记录过去剩下的东西,如果和现在的加起来刚好能控制在0.5内,那么就直接取整,否则加1是吧。。。

各位大佬还是看代码理解一下...

果然还是我太菜了awa

20190710双人开黑CF模拟赛的更多相关文章

  1. 20190708三人开黑CF模拟赛

    7月8号晚上8点和两位巨佬开了一场虚拟cf: [Helvetic Coding Contest 2018 online mirror (teams allowed, unrated)] 我这么蔡,只A ...

  2. 20190728三人开黑517codingACM模拟赛

    三人组队开黑ACM膜你赛 果然我最蔡 我就写了ACF所以就写这些吧awa Problem A 人话:给你一个w×h的矩形蛋糕,然后告诉你两个蜡烛的坐标,两个蜡烛都在网格点上且不在蛋糕边缘,问如何切一刀 ...

  3. 2014-11-2 NOIP模拟赛1

    Noip2009 团结模拟赛如题目理解困难,请自行阅读或参考样例.内存限制均为 256MB,时间限制均为 1s.出题人不会 故意 在题目中设置陷阱,但请自己注意程序的正确性.IO 文件名(.in/.o ...

  4. 2014-10-31 NOIP模拟赛

        10.30 NOIp  模拟赛   时间 空间 测试点 评测方式 挖掘机(dig.*) 1s 256M 10 传统 黑红树(brtree.*) 2s 256M 10 传统 藏宝图(treas. ...

  5. [NOIP2018模拟赛10.23]发呆报告

    闲扯 考场看了眼题目感觉很难,一个小时敲完了所有暴力...嗯然后就在那里发呆什么事也没做 T3考场上把数据结构想了个遍都不会完成1操作,现在看这种思路其实之前也接触过... 比较玄学的一件事情就是T1 ...

  6. ZROI 19.08.07模拟赛

    传送门 写在前面:为了保护正睿题目版权,这里不放题面,只写题解. "正睿从来没有保证,模拟赛的题目必须原创." "文案不是我写的,有问题找喵老师去."--蔡老师 ...

  7. 冲刺$\mathfrak{CSP-S}$集训模拟赛总结

    开坑.手懒并不想继续一场考试一篇文. 既没必要也没时间侧边栏的最新随笔题解反思相间也丑 而且最近越来越懒了竟然都不写题解了……开坑也是为了督促自己写题解. 并不想长篇大论.简要题解也得写啊QAQ. 目 ...

  8. NOIP模拟赛 6.29

    2017-6-29 NOIP模拟赛 Problem 1 机器人(robot.cpp/c/pas) [题目描述] 早苗入手了最新的Gundam模型.最新款自然有着与以往不同的功能,那就是它能够自动行走, ...

  9. NOIP模拟赛20161022

    NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...

随机推荐

  1. mysql主从之基于atlas读写分离

    一 mysql读写分离的概念 写在主库,主库一般只有一个,读可以分配在多个从库上,如果写压力不大的话,也能把读分配到主库上. 实现是基于atlas实现的,atlas是数据库的中间件,程序只需要连接at ...

  2. 关于有向图走“无限次”后求概率/期望的口胡/【题解】HNCPC2019H 有向图

    关于有向图走"无限次"后求概率/期望的口胡/[题解]HNCPC2019H 有向图 全是口胡 假了不管 讨论的都是图\(G=(V,E),|V|=n,|E|=m\)上的情况 " ...

  3. A记录都不懂,怎么做开发Leader?

    开发 Leader 和一线开发的区别在于:普通一线开发很多时候都只接触业务编码,不需要关注除开发之外的其他事情.但是作为一个开发 Leader,不仅仅需要懂开发层面的东西,还需要懂得运维层面的东西. ...

  4. Oracle 数据泵expdq,impdq

    使用数据泵技术实现逻辑备份 数据泵概述 数据泵(DATA PUMP)是一种在数据库之间.数据库与操作系统之间,高速传输数据的技术(10g推出). 逻辑备份概述 逻辑备份是对数据库对象(如用户.表.存储 ...

  5. springboot + freemarker 实现计算器

    使用RequestParam("") 接受参数 其后参数有自动类型转换的作用 @RequestParam("firstNumber") double first ...

  6. k8s-自动安装

    操作环境: centos7.3 node102-master-192.168.100.102 node103-node1-192.168.100.103 node104-node2-192.168.1 ...

  7. 实现antd下拉框动态添加内容(与数据库交互)

    antd下拉控件的动态内容添加(与数据库交互) antd这个框架给开发带来了极大的方便,但同时,我认为还有一些不方便的地方:常用的逻辑在文档中没有体现.需要前端开发经验的人才能快速上手,而我刚刚接触这 ...

  8. 动态规划,以LeetCode-CombinationSumIV问题为例

    简介: 动态规划问题面试中经常遇到的问题之一,按照动态规划的一般定义,其一般解法在于将大问题分解为很多小问题去解决,但是我在遇到很多实际的问题时,想法都是强行的去将问题分解,而忽略了分解的必要性和途径 ...

  9. 【转】ArcGIS Server 站点架构-Web Adaptor

    GIS 服务器内置了Web服务器,如果我想用我自己企业内部的服务器,该怎么做? 多个GIS服务器集群又如何做? …… 有问题,说明我们在思考,这也是我们希望看到的,因为只有不断的思考,不断的问自己为什 ...

  10. Java 中的foreach(增强for循环)

    foreach概述 增强for循环:底层使用的是送代器,使用for循环的格式,简化了送代器的书写,foreach是JDK1.5之后出现的新特性 使用增强for循环 遍历集合 /** * 遍历集合 * ...