前置扯淡

赛前:这场\(Div2\)呀,那我写\(3\)题就行,\(D\)题尽力就好

赛中:啊啊,\(ABC\)我全过了\(pretest\),我太强了!!这把上蓝稳了

赛后:\(woc\),为啥被\(hack\)了两道!!\(newbie\) \(yspm\)认证成功了……

题目&&解答

A.Display The Number

link

思路

水题一道,直接\(1\)和\(7\)随便输出就行

CODE

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. namespace yspm{
  5. inline int read()
  6. {
  7. int res=0,f=1; char k;
  8. while(!isdigit(k=getchar())) if(k=='-') f=-1;
  9. while(isdigit(k)) res=res*10+k-'0',k=getchar();
  10. return res*f;
  11. }
  12. inline void work()
  13. {
  14. int x=read(); if(x%2==0) while(x) cout<<1,x-=2;
  15. else{cout<<7; x-=3; while(x) cout<<1,x-=2;}
  16. return cout<<endl,void();
  17. }
  18. signed main()
  19. {
  20. int T=read(); while(T--) work();
  21. return 0;
  22. }
  23. }
  24. signed main(){return yspm::main(); }

B.Infinite Prefixes

link

思路

这个题细节有一点点多

预处理出来\(s\)串中每一个前缀的\(0\)和\(1\)的差值,记为\(a[\space ]\)

看\(a[s.length()]\)的值

\(1^0\) 如果为\(0\),就考虑正无穷的情况

如果有一个\(a_i\)的值与\(x\)相同,就直接为正无穷,否则为\(0\)

\(2^0\) 如果不为\(0\),就考虑同余

当前位置的\(a[\space]\)值和\(x\)是否关于\(a[s.length()]\)同余即可

还要注意正负性

CODE

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. namespace yspm{
  5. inline int read()
  6. {
  7. int res=0,f=1; char k;
  8. while(!isdigit(k=getchar())) if(k=='-') f=-1;
  9. while(isdigit(k)) res=res*10+k-'0',k=getchar();
  10. return res*f;
  11. }
  12. const int N=1e5+10;
  13. int a[N],n,x; string s;
  14. inline void work()
  15. {
  16. a[0]=0; n=read(); x=read(); cin>>s;
  17. for(int i=0;i<n;++i)
  18. {
  19. if(s[i]=='0') a[i+1]=a[i]+1;
  20. else a[i+1]=a[i]-1;
  21. }
  22. int p=a[n];
  23. if(!p)
  24. {
  25. for(int i=1;i<=n;++i)
  26. {
  27. if(a[i]==x) return puts("-1"),void();
  28. }puts("0");
  29. }
  30. else
  31. {
  32. int ans=(x==0);
  33. for(int i=1;i<=n;++i)
  34. {
  35. if((x-a[i])*p>=0&&(x-a[i])%p==0) ++ans;
  36. } printf("%lld\n",ans);
  37. }
  38. return ;
  39. }
  40. signed main()
  41. {
  42. int T=read(); while(T--) work();
  43. return 0;
  44. }
  45. }
  46. signed main(){return yspm::main(); }

这个题当时没有想到怎么处理正负性,这个乘积与\(0\)的大小关系还是可以进行频繁利用的

C. Obtain The String

link

思路

其实就是一个简单的模拟,里面套了一个\(upper_bound\)(或者说二分)

预处理\(s\)中每一个字母出现的位置(开\(26\)个\(vector\)),每一次直接模拟\(t\)中的字母,记录最后出现的位置\(las\)

1.如果当前\(t\)中的字母\(s\)中没有,就直接\(puts("-1")\)

2.就直接二分\(las\)后该字母出现的第一个位置,更新\(las\)的值,如果没有了就\(++ans\),\(las\)为该字母第一个出现位置(结论由简单贪心直接成立)

CODE

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. namespace yspm{
  5. inline int read()
  6. {
  7. int res=0,f=1; char k;
  8. while(!isdigit(k=getchar())) if(k=='-') f=-1;
  9. while(isdigit(k)) res=res*10+k-'0',k=getchar();
  10. return res*f;
  11. }
  12. const int N=1e5+10;
  13. vector<int> vec[26];
  14. string s,t;
  15. int ls,lt,ans;
  16. inline void work()
  17. {
  18. cin>>s>>t; for(int i=0;i<26;++i) vec[i].clear(); ans=1;
  19. ls=s.length(); lt=t.length();
  20. for(int i=1;i<=ls;++i) vec[s[i-1]-'a'].push_back(i-1);
  21. int las=-1;
  22. for(int i=0;i<lt;++i)
  23. {
  24. int tmp=t[i]-'a';
  25. if(vec[tmp].empty()){return puts("-1"),void();}
  26. if(vec[tmp].back()<=las)++ans,las=vec[tmp].front();
  27. else las=vec[tmp][upper_bound(vec[tmp].begin(),vec[tmp].end(),las)-vec[tmp].begin()];
  28. }
  29. return cout<<ans<<endl,void();
  30. }
  31. signed main()
  32. {
  33. int T=read(); while(T--) work();
  34. return 0;
  35. }
  36. }
  37. signed main(){return yspm::main(); }

D.Same GCDs

link

Solution

link

E.Permutation Separation

link

Solution

link

F.Good Contest

link

Solution

这个题被吐槽为跟\(APIO2016\) 划艇那道有一点像

光看题目描述真的非常像

但是做法还是不很会,留坑待填

Codeforces Educational Round 81 解题报告的更多相关文章

  1. Codeforces Global Round 1 解题报告

    A 我的方法是: #include<bits/stdc++.h> using namespace std; #define int long long typedef long long ...

  2. Codeforces Educational Round 92 赛后解题报告(A-G)

    Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...

  3. Codeforces Educational Round 33 题解

    题目链接   Codeforces Educational Round 33 Problem A 按照题目模拟,中间发现不对就直接输出NO. #include <bits/stdc++.h> ...

  4. [CodeForces]Educational Round 52

    幸好我没有打这场,我VP的时候在C题就卡死了,我果然还是太菜了. A Vasya and Chocolate 题意:一个巧克力\(c\)元,买\(a\)赠\(b\),一共有\(n\)元,问能买几个巧克 ...

  5. Codeforces Round #300 解题报告

    呜呜周日的时候手感一直很好 代码一般都是一遍过编译一遍过样例 做CF的时候前三题也都是一遍过Pretest没想着去检查... 期间姐姐提醒说有Announcement也自信不去看 呜呜然后就FST了 ...

  6. Codeforces Round #513解题报告(A~E)By cellur925

    我是比赛地址 A:Phone Numbers $Description$:给你一串数字,问你能组成多少开头为8的11位电话号码. $Sol$:统计8的数量,与$n$%11作比较. #include&l ...

  7. Codeforces Round #302 解题报告

    感觉今天早上虽然没有睡醒但是效率还是挺高的... Pas和C++换着写... 544A. Set of Strings   You are given a string q. A sequence o ...

  8. Codeforces Round #301 解题报告

    感觉这次的题目顺序很不合理啊... A. Combination Lock   Scrooge McDuck keeps his most treasured savings in a home sa ...

  9. codeforces B. Simple Molecules 解题报告

    题目链接:http://codeforces.com/problemset/problem/344/B 题目意思:这句话是解题的关键: The number of bonds of an atom i ...

随机推荐

  1. AndroidAutoLayout

    AndroidAutoLayout [DEPRECATED]Android屏幕适配方案,直接填写设计图上的像素尺寸即可完成适配. 目前没有精力,已停止维护,使用前务必看明白代码,明确该方案可以解决自身 ...

  2. sqli-labs注入lesson1-2闯关秘籍

    ·lesson1 1.判断是否存在注入,并判断注入的类型 其实根据第一关提示 判断注入类型 输入下面的语句进行测试: ?id= 返回界面如下图:说明存在 字符型注入 2. 使用order by 猜测S ...

  3. comparable and comparator 比较

      转:http://www.yingjiesheng.com/job-002-393-132.html 一.前言 在Java集合框架里面,各种集合的操作很大程度上都离不开Comparable和Com ...

  4. UVALive 4487 Exclusive-OR 加权并查集神题

    已知有 x[0-(n-1)],但是不知道具体的值,题目给定的信息 只有 I P V,说明 Xp=V,或者 I P Q V,说明 Xp ^ Xq=v,然后要求回答每个询问,询问的是 某任意的序列值 Xp ...

  5. great vision|be quite honest with you

    won a national championship拿到全国冠军 come play for you参加你的队伍 Really not true事实并非如此 Being the Socratic p ...

  6. mysql四种事务隔离级别

    mysql事务并发问题 ACID什么的就不啰嗦了.mysql多个事务并发的时候,可能会出现如下问题: 1. 更新丢失 即两个事务同时更新某一条数据,后执行的更新操作会覆盖先执行的更新操作,导致先执行的 ...

  7. SpringCloud学习之Config分布式配置中心(八)

    统一配置中心概述 如果微服务架构中没有使用统一配置中心时,所存在的问题: 配置文件分散在各个项目里,不方便维护 配置内容安全与权限,实际开发中,开发人员是不知道线上环境的配置的 更新配置后,项目需要重 ...

  8. Integer类的装箱和拆箱实现

    反编译:是指通过对他人软件的目标程序(比如可执行程序)进行“逆向分析.研究”工作,以推导出他人的软件产品所使用的思路.原理.结构.算法.处理过程.运行方法等设计要素,某些特定情况下可能推导出源代码.反 ...

  9. {转} 深入理解 HTTP Session

    session在web开发中是一个非常重要的概念,这个概念很抽象,很难定义,也是最让人迷惑的一个名词,也是最多被滥用的名字之一,在不同的场合,session一次的含义也很不相同.这里只探讨HTTP S ...

  10. libcurl在windows下的使用

    curl在linux下很好用,但到了windows下写程序却没办法使用了,这时候可以使用libcurl库 libcurl库的编译网上很多,我就不一一赘述了,curl的官方网站:https://curl ...