Educational Codeforces Round 82 (Rated for Div. 2) A-E代码(暂无记录题解)
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代码(暂无记录题解)的更多相关文章
- Educational Codeforces Round 82 (Rated for Div. 2)
题外话 开始没看懂D题意跳了,发现F题难写又跳回来了.. 语文好差,码力好差 A 判第一个\(1\)跟最后一个\(1\)中\(0\)的个数即可 B 乘乘除除就完事了 C 用并查集判一下联通,每个联通块 ...
- 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; ][]; ...
- Educational Codeforces Round 82 (Rated for Div. 2)D(模拟)
从低位到高位枚举,当前位没有就去高位找到有的将其一步步拆分,当前位多余的合并到更高一位 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h&g ...
- [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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- 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 ...
随机推荐
- 使用github--stanfordnlp--glove训练自己的数据词向量
1.准备语料 准备好自己的语料,保存为txt,每行一个句子或一段话,注意要分好词.将分好词的语料保存为×××.txt 2.准备源码 下载地址:https://github.com/stanfordnl ...
- openssl 自签名证书SHA1加密算法
openssl genrsa -out privkey.pem 2048 openssl req -new -key privkey.pem -sha1 -out cert.csr openssl r ...
- [Redis-CentOS7]Redis发布订阅操作(七)
发布订阅 发布:打电话 订阅:接电话 订阅频道 127.0.0.1:6379> SUBSCRIBE msg Reading messages... (press Ctrl-C to quit) ...
- 第三篇 SpringBoot整合log4j2详解
源代码:https://pan.baidu.com/s/1d1Lwv1gIvVNltIKVWeEseA 提取码:wff0 SpringBoot整合Log4j2步骤: 1.删除spring-boot-s ...
- 智和网管平台SugarNMS赋能AI智能化运维
11月14日,由<网络安全和信息化>和IT运维网联合主办的2019(第十届) IT运维大会上海站在锦荣国际大酒店如期召开.运维领域权威专家.技术领袖.各类运维相关技术产品提供商及服务商共同 ...
- 【Python3爬虫】一次应对JS反调试的记录
一.前言简介 在前面已经写过关于 JS 反调试的博客了,地址为:https://www.cnblogs.com/TM0831/p/12154815.html.但这次碰到的网站就不一样了,这个网站并不是 ...
- mybatis 通过配置父类数据源连接和关闭数据,进行junit单元测试
来源:https://blog.csdn.net/Bigbig_lyx/article/details/80646005 解决问题,单元测试没经过单独配置,每个测试方法中要添加配置数据源 一:配置父类 ...
- C++中的多态及虚函数大总结
多态是C++中很关键的一部分,在面向对象程序设计中的作用尤为突出,其含义是具有多种形式或形态的情形,简单来说,多态:向不同对象发送同一个消息,不同的对象在接收时会产生不同的行为.即用一个函数名可以调用 ...
- JN_0019:CMD命令窗口常用操作
1,回到根目录下 cd\ 2,
- Winfrom中From控件的重绘
重绘目的: 1. 满足非默认主题下的标题栏样式 2. 在保留停靠功能的同时进行重绘. 代码如下: public partial class FormEx: Form { public FormEx() ...