A. Erasing Zeroes (模拟)

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+;
int main(){
int t;cin>>t;
while(t--){
string s;cin>>s;
bool f1 = ,f2 = ;
int cnt = ;
int ans = ;
for(int i = ;i<s.length();i++){
if(s[i] == ''){
if(f1 == ) {
ans+=cnt;
cnt = ;
f1 = ;
}
if(f1 == ) f1 = ;
}
else{
if(f1 == ) cnt++;
}
}
cout<<ans<<endl;
}
return ;
}

B. National Project (数学题 周期计算)

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+;
int main(){
int t;cin>>t;
while(t--){
ll n,g,b;
cin>>n>>g>>b;
ll tn = n;
if(n% == ) n = n/+;
else n = n/;
if(n<=g ) {
cout<<tn<<endl;continue;
}
else{
ll t = g+b;//一个周期
ll c = n/g;//至少需要几个周期
if(n%g == ) {
if(c*t-b<tn) cout<<tn<<endl;
else cout<<c*t-b<<endl;
continue;
}
ll d = n%g;
ll ans = c*t+d;
if(ans<tn) ans+=(tn-ans);
cout<<ans<<endl;
continue;
}
// 4 1 1
}
return ;
}

C. Perfect Keyboard (dfs 图论)

 #include<bits/stdc++.h>
using namespace std;
struct node{
vector<int> v;
}g[];
string ans;
int vis[];
void init(){
for(int i = ;i<;i++) g[i].v.clear(),vis[i] = ;
ans = "";
}
void dfs(int cur){
vis[cur] = ,ans+='a'+cur;
for(int i = ;i<g[cur].v.size();i++){
if(!vis[g[cur].v[i]]) dfs(g[cur].v[i]);
}
}
void solve(){
string s;
cin>>s;
init();
map<pair<int,int>,int > m;
for(int i = ;i<s.length();i++){
int a = s[i-] - 'a',b = s[i] - 'a';
if(a<b) swap(a,b);
if(m[{a,b}] == ){
m[{a,b}] = ;
g[a].v.push_back(b);
g[b].v.push_back(a);
}
}
for(int i = ;i<;i++){
if(g[i].v.size()>) {
cout<<"NO"<<endl;
return;
}
}
for(int i = ;i<;i++){
if(!vis[i] && g[i].v.size()<){
dfs(i);
}
}
if(ans.length() == ) {
cout<<"YES"<<endl;
cout<<ans<<endl;
return;
}
else{
cout<<"NO"<<endl;
}
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
return ;
}

D. Fill The Bag(贪心 二进制位运算 状态压缩)

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+;
const int maxBit = ;
int cnt[maxBit];
void solve(){
ll n;int m;
scanf("%lld%d",&n,&m);
memset(cnt,,sizeof(cnt));
ll sum = ;
for(int i = ;i<=m;i++) {
ll x;
scanf("%lld",&x);
sum+=x;
for(int j = ;j<=maxBit;j++){
if((x>>j)& == ) {
cnt[j+]++;
break;
}
}
}
if(sum<n) {
cout<<-<<endl;return ;
}
int ans = ;
for(int i = ;i<=maxBit;i++){
if((n>>(i-))&){
if(!cnt[i]){
int indx = -;
for(int j = i;j<=maxBit;j++){
if(cnt[j]) {
indx = j;
break;
}
}
while(indx!=i){
cnt[indx]--,cnt[indx-]+=,ans++,indx--;
}
// n^=(1<<(i-1));
}
cnt[i]--;
}
cnt[i+] += cnt[i]/;
}
cout<<ans<<endl;
}
//
int main(){
int t;
cin>>t;
while(t--){
solve();
}
return ;
}

E. Erase Subsequences (字符串上dp)

 #include<bits/stdc++.h>
using namespace std;
const int maxn = ;
int dp[maxn][maxn];
bool check(string s,string t){
int indx = ;
for(int i = ;i<s.length();i++){
if(t[indx] == s[i]) indx++;
}
if(indx == t.length()) return true;
return false;
}
bool check(string s,string t1,string t2){
memset(dp,-,sizeof(dp));
dp[][] = ;
for(int i = ;i<s.length();i++){
for(int j = ;j<=t1.size();j++){
if(dp[i][j]<) continue;
if(j<t1.size() && s[i] == t1[j]){
dp[i+][j+] = max(dp[i+][j+],dp[i][j]);
}
if(dp[i][j]<t2.size() && s[i] == t2[dp[i][j]]){
dp[i+][j] = max(dp[i+][j],dp[i][j]+);
}
dp[i+][j] = max(dp[i+][j],dp[i][j]);
}
}
if(dp[s.length()][t1.length()] == t2.length()) return true;
return false;
}
void solve(){
string s,t;
cin>>s>>t;
if(check(s,t)){
cout<<"YES"<<endl;
return;
}
for(int i = ;i<t.length()-;i++){
string t1 = t.substr(,i+);
string t2 = t.substr(i+,t.size());
if(check(s,t1,t2)){
cout<<"YES"<<endl;
return;
}
}
cout<<"NO"<<endl;
return;
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
return ;
}

Educational Codeforces Round 82 (Rated for Div. 2) A-E代码(暂无记录题解)的更多相关文章

  1. Educational Codeforces Round 82 (Rated for Div. 2)

    题外话 开始没看懂D题意跳了,发现F题难写又跳回来了.. 语文好差,码力好差 A 判第一个\(1\)跟最后一个\(1\)中\(0\)的个数即可 B 乘乘除除就完事了 C 用并查集判一下联通,每个联通块 ...

  2. Educational Codeforces Round 82 (Rated for Div. 2)E(DP,序列自动机)

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],t[]; int n,m; ][]; ...

  3. Educational Codeforces Round 82 (Rated for Div. 2)D(模拟)

    从低位到高位枚举,当前位没有就去高位找到有的将其一步步拆分,当前位多余的合并到更高一位 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h&g ...

  4. [CF百场计划]#3 Educational Codeforces Round 82 (Rated for Div. 2)

    A. Erasing Zeroes Description You are given a string \(s\). Each character is either 0 or 1. You wan ...

  5. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  6. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  7. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  8. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  9. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

随机推荐

  1. [jQuery]jQuery链式编程(六)

    链式编程 节约代码量 <button>快速</button> <button>快速</button> <button>快速</butt ...

  2. js 常用总结

    1.截取字符串 var a="/s/d";   console.log(a.substr(0,a.indexOf("/",1)))  // 得到/s 2. // ...

  3. HTTP 1.1状态代码及其含义

    HTTP 1.1状态代码及其含义 100  Continue  初始的请求已经接受,客户应当继续发送请求的其余部分.(HTTP 1.1新) 101  Switching Protocols  服务器将 ...

  4. ID生成器之——别人家的方案and自家的方案

    “叮咚,叮咚……”,微信提示音一声接一声,声音是那么的频繁,有妖气,待俺去看一看. 这天刚吃完午饭,打开微信,发现我们的技术讨论组里有 100 多条未读消息,心想,是不是系统出问题了?怎么消息那么频繁 ...

  5. Centos7 使用Docker 部署mssql 2017

    mssql是.NET的标配,一般使用.NET的人基本都用mssql. 以前mssql只能支持windows平台,从微软打出 拥抱开源 的口号开始,mssql的2017 版本,开始支持linux系统. ...

  6. .NET Core MVC下的TagHelper

    .NET web开发者在开发过程中,一定都踩过的坑,明明修改了js文件,可是部署到生产环境,客户反馈说:“还是报错啊”..然后一脸懵逼的去服务器上看文件,确实已经更新了.有经验的coder可能就想到了 ...

  7. NServiceBus 入门到精通(一)

    什么是NServiceBus?NServiceBus 是一个用于构建企业级 .NET系统的开源通讯框架.它在消息发布/订阅支持.工作流集成和高度可扩展性等方面表现优异,因此是很多分布式系统基础平台的理 ...

  8. [javascript] test() 方法进行正则验证

    test() 方法用于检测一个字符串是否匹配某个模式 最近遇到的某业务中进行发票抬头的正则验证如下: console.log(/^[a-zA-Z\u4e00-\u9fa5\s()()<>& ...

  9. Ubuntu切换为阿里镜像源

    前言 在VM虚拟机搭建Ubuntu系统学习或者测试时,常常要使用apt安装测试,但是由于系统自带的下载源在国外服务器上,下载速度慢的无法忍受.所以我们需要切换为国内镜像源,能显著加快安装包下载速度. ...

  10. 常用 PostgreSQL 脚本

    数据定义 数据库 -- 创建数据库 -- https://www.postgresql.org/docs/current/static/multibyte.html -- database_name, ...