前置扯淡

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

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

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

题目&&解答

A.Display The Number

link

思路

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

CODE

#include<bits/stdc++.h>
using namespace std;
#define int long long
namespace yspm{
inline int read()
{
int res=0,f=1; char k;
while(!isdigit(k=getchar())) if(k=='-') f=-1;
while(isdigit(k)) res=res*10+k-'0',k=getchar();
return res*f;
}
inline void work()
{
int x=read(); if(x%2==0) while(x) cout<<1,x-=2;
else{cout<<7; x-=3; while(x) cout<<1,x-=2;}
return cout<<endl,void();
}
signed main()
{
int T=read(); while(T--) work();
return 0;
}
}
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

#include<bits/stdc++.h>
using namespace std;
#define int long long
namespace yspm{
inline int read()
{
int res=0,f=1; char k;
while(!isdigit(k=getchar())) if(k=='-') f=-1;
while(isdigit(k)) res=res*10+k-'0',k=getchar();
return res*f;
}
const int N=1e5+10;
int a[N],n,x; string s;
inline void work()
{
a[0]=0; n=read(); x=read(); cin>>s;
for(int i=0;i<n;++i)
{
if(s[i]=='0') a[i+1]=a[i]+1;
else a[i+1]=a[i]-1;
}
int p=a[n];
if(!p)
{
for(int i=1;i<=n;++i)
{
if(a[i]==x) return puts("-1"),void();
}puts("0");
}
else
{
int ans=(x==0);
for(int i=1;i<=n;++i)
{
if((x-a[i])*p>=0&&(x-a[i])%p==0) ++ans;
} printf("%lld\n",ans);
}
return ;
}
signed main()
{
int T=read(); while(T--) work();
return 0;
}
}
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

#include<bits/stdc++.h>
using namespace std;
#define int long long
namespace yspm{
inline int read()
{
int res=0,f=1; char k;
while(!isdigit(k=getchar())) if(k=='-') f=-1;
while(isdigit(k)) res=res*10+k-'0',k=getchar();
return res*f;
}
const int N=1e5+10;
vector<int> vec[26];
string s,t;
int ls,lt,ans;
inline void work()
{
cin>>s>>t; for(int i=0;i<26;++i) vec[i].clear(); ans=1;
ls=s.length(); lt=t.length();
for(int i=1;i<=ls;++i) vec[s[i-1]-'a'].push_back(i-1);
int las=-1;
for(int i=0;i<lt;++i)
{
int tmp=t[i]-'a';
if(vec[tmp].empty()){return puts("-1"),void();}
if(vec[tmp].back()<=las)++ans,las=vec[tmp].front();
else las=vec[tmp][upper_bound(vec[tmp].begin(),vec[tmp].end(),las)-vec[tmp].begin()];
}
return cout<<ans<<endl,void();
}
signed main()
{
int T=read(); while(T--) work();
return 0;
}
}
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. ASP.NET Identity实现分布式Session,Docker+Nginx+Redis+ASP.NET CORE Identity

    零.背景介绍 在学习ASP.NET CORE开发的过程中,身份认证是必须考虑的一项必要的组件.ASP.NET CORE Identity是由微软官方开发的一整套身份认证组件,兼具完整性和自由度.Doc ...

  2. 大二暑假第六周总结--开始学习Hadoop基础(五)

    简单学习数据仓库HIVE HIVE是一个构建于Hadoop顶端的数据仓库工具 支持大规模数据存储,分析,具有良好的可扩展性 某种程度上可以看做是用户编程接口,本身不存储和处理数据 依赖分布式系统HDF ...

  3. 初学C#之变量、占位符、转义符、还有就是类型转换

    ㈠.定义变量 先定义再赋值 int Num1; Num1 = ; 定义的同时赋值 ; 定义多个变量同时赋值,先决条件变量类型相同,例如: string phome = "1891250888 ...

  4. PAT Advanced 1003 Emergency (25) [Dijkstra算法]

    题目 As an emergency rescue team leader of a city, you are given a special map of your country. The ma ...

  5. python yield 使用示例

    1.yield由于创建迭代器 def deal(): tmp = [] for i in range(20): tmp.append(i) if i % 4 == 0: yield tmp tmp = ...

  6. SQL基础之JDBC、连接池

    JDBC JDBC四个核心对象 这几个类都是在java.sql包中 DriverManager(类): 数据库驱动管理类.这个类的作用:1)注册驱动; 2)创建java代码和数据库之间的连接,即获取C ...

  7. group_concat用法以及字符串太长显示不全

    由于group_concat默认的长度是1024,所以要将最大长度修改 首先执行 SET SESSION group_concat_max_len = 10240;#一次查询有效 然后再进行拼接 se ...

  8. NRF24L01多对一、多通道通讯关键代码

    要想24L01多通道通讯成功,务必先单通道调试成功,并且懂得这块芯片通讯的一些基本知识.   一.基本的通讯条件 1.接收端的接收地址(RX_ADDR_Px)等于发射端的发射送地址(TX_ADDR) ...

  9. 深入理解 Java —— GC 机制

    1. 基础知识 1.1 什么是垃圾回收? 程序的运行必然需要申请内存资源,无效的对象资源如果不及时处理就会一直占有内存资源,最终将导致内存溢出,所以对内存资源的管理非常重要. 垃圾回收就是对这些无效资 ...

  10. 剑指offer第40题

    package com.yan.offer; /** * 题目描述: * * 一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序找出这两个只出现一次的数字. * * @author Ya ...