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. Java基础环境配置及HelloWorld

    一.什么是JDK,JRE JDK(Java Development Kit Java开发工具包) JDK是提供给Java开发人员使用的,其中包含了java的开发工具,也包括了JRE.所以安装了JDK, ...

  2. python安装模块速度慢的解决方法

    1.Win+R,cmd 2.pip install pqi 3.pqi use aliyun

  3. 珠峰-webpack1

    #### sourcemap #### watch 选项 #### 3个常用的小插件. #### 前端webpack的自己的mock #### 服务端引用了webpack的插件. #### resol ...

  4. nginx启动报错nginx: [error] open() "/usr/local/etc/nginx/logs/nginx.pid" failed

    问题:nginx启动的时候会报丢失pid的错误 nginx: [error] open() “/usr/local/var/run/nginx.pid” failed 解决方案: sudo nginx ...

  5. VS2015中使用qt开发客户端,QPluginLoader加载dll为null的解决办法

    1,问题重现: 使用vs2015开发一款qt软件,使用了QPluginLoader动态加载插件的方式,调试的时候,发现dll模块没有加载进来,debug发现QPluginLoader的instance ...

  6. http报文解析

    http报文结构 报文首部 起始行 请求报文的起始行: 方法(method) request-URL version(http协议版本) 响应报文的起始行 HTTP响应码 请求头 通用首部 请求首部 ...

  7. 多线程共享变量和 AsyncLocal

    >>返回<C# 并发编程> 1. 简介 2. 异步下的共享变量 3. 解析 AsyncLocal 3.1. IAsyncLocalValueMap 的实现 3.2. 结论 1. ...

  8. HTML连载70-相片墙、盒子阴影和文字阴影

    一. 制作一个相片墙 二. <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...

  9. 关于HashMap中的扰动函数的疑问

    最近再看jdk8的hashmap源码,当看到这一步的时候有点疑问,去网上搜了一下,看到的所有文章基本上都是一篇抄一篇的(反正目前各大社区就是这么个状况),那个意思就是让高16位也参与运算,增加结果的随 ...

  10. CF1311E Construct the Binary Tree

    膜这场比赛的 \(rk1\) \(\color{black}A\color{red}{lex\_Wei}\) 这题应该是这场比赛最难的题了 容易发现,二叉树的下一层不会超过这一层的 \(2\) 倍,所 ...