当前位置: 首页 > news >正文

赣州企业网站建设公司建设项目环境影响备案网站

赣州企业网站建设公司,建设项目环境影响备案网站,河北涿州建设局网站,环保网站模板下载比赛链接:Dashboard - Codeforces Round 855 (Div. 3) - Codeforces A:模拟 题意:给定一个字符串,问这个字符串是不是猫叫。定义是猫叫得字符串: 1:必须由大写或小写得M(m),E&…

比赛链接:Dashboard - Codeforces Round 855 (Div. 3) - Codeforces

A:模拟 

题意:给定一个字符串,问这个字符串是不是猫叫。定义是猫叫得字符串:

1:必须由大写或小写得'M(m)','E(e)','O(o)','W(w)'组成

2:字符串起始必须是M(大写或者小写都行)紧跟其后必须是E,接着是O,接着是W,然后结束。

分析:根据条件,将字符串扫一遍即可

代码:

#include <bits/stdc++.h>
#define pi acos(-1)
#define int long long
#define PII pair<int,int>
#define all(v) v.begin(),v.end()
#define INF 0x3f3f3f3f3f3f3f3f
#define fs(a) cout<<fixed<<setprecision(a)<< //fs(4)(1.0/3)=0.3333//保留a位小数
#define read() freopen("input.txt","r",stdin)
#define output() freopen("output.txt","w",stdout)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=2e5+10;
const int mod = 1e9+7;
const int Mod = 998244353;
int lowbit(int x){return x&(-x);}
int up(int a,int b){return a<0?a/b:(a+b-1)/b;}//       a/b向上取整
int quickpow(int a,int n){int ans=1;while(n){if(n&1){ans*=a,ans%=Mod;}a*=a;a%=Mod;n>>=1;}return ans;}//快速幂
int qc(int a,int b,int p){int ans=0;while(b){if(b&1){ans+=a,ans%=p;}a*=2;a%=p;b>>=1;}return ans;}//快速乘 a*b%pinline void solve(){int n,i=0;string s;cin>>n>>s;if(n<4||(s[0]!='M'&&s[0]!='m')){cout<<"NO\n";return;}while(s[i]=='M'||s[i]=='m') i++;if(s[i]!='E'&&s[i]!='e'){cout<<"NO\n";return;}while(s[i]=='E'||s[i]=='e') i++;if(s[i]!='O'&&s[i]!='o'){cout<<"NO\n";return;}while(s[i]=='O'||s[i]=='o') i++;if(s[i]!='W'&&s[i]!='w'){cout<<"NO\n";return;}while(s[i]=='W'||s[i]=='w') i++;if(i==n) cout<<"YES\n";else cout<<"NO\n"; 
}signed main(){fast;int T;cin>>T;while(T--) solve();
}              

 B:贪心

题意: 给定一个字符串,相同字符的大小写为一个匹配对(例如:Aa)。你可以使用任意次操作,使得将大写字母改为小写字母,或者小写字母改为大写字母。问最多有多少个匹配对

分析:我们发现,尽可能的使用完操作次数,我们才会得到最大匹配对数。我们只需要记录一下相同字母对应的大小写个数,然后可以先计算原始的匹配对,再计算操作后的匹配对数。具体看代码

#include <bits/stdc++.h>
#define pi acos(-1)
#define int long long
#define PII pair<int,int>
#define all(v) v.begin(),v.end()
#define INF 0x3f3f3f3f3f3f3f3f
#define fs(a) cout<<fixed<<setprecision(a)<< //fs(4)(1.0/3)=0.3333//保留a位小数
#define read() freopen("input.txt","r",stdin)
#define output() freopen("output.txt","w",stdout)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=2e5+10;
const int mod = 1e9+7;
const int Mod = 998244353;
int lowbit(int x){return x&(-x);}
int up(int a,int b){return a<0?a/b:(a+b-1)/b;}//       a/b向上取整
int quickpow(int a,int n){int ans=1;while(n){if(n&1){ans*=a,ans%=Mod;}a*=a;a%=Mod;n>>=1;}return ans;}//快速幂
int qc(int a,int b,int p){int ans=0;while(b){if(b&1){ans+=a,ans%=p;}a*=2;a%=p;b>>=1;}return ans;}//快速乘 a*b%p
int u[N],l[N];inline void solve(){int n,k;string s;cin>>n>>k>>s;memset(u,0,sizeof u);memset(l,0,sizeof l);for(int i=0;i<n;i++){if(isupper(s[i])) u[s[i]-'A']++;else l[s[i]-'a']++;}int ans=0;for(int i=0;i<26;i++){int minn=min(u[i],l[i]);ans+=minn;u[i]-=minn;l[i]-=minn;if(u[i]>=2){if(u[i]/2<=k) ans+=u[i]/2,k-=u[i]/2;else ans+=k,k=0;}else if(l[i]>=2){if(l[i]/2<=k) ans+=l[i]/2,k-=l[i]/2;else ans+=k,k=0;}}cout<<ans<<"\n";
}signed main(){fast;int T;cin>>T;while(T--) solve();
}              

 C:模拟+贪心(大根堆)

 

题意:你的初始分数为0。给定一堆牌,每个牌有一定的数字,给定顺序去摸取。如果摸到非0牌,则可以选择将此牌放在自己牌堆的堆顶,或者放弃这张牌。如果摸到数字为0的牌,则自己牌堆堆顶的数字会加到你的分数里面,并且标记这张牌已经使用过,问你能得到的最大分数。

分析:根据题意,我们发现,在摸到非0牌之前,我们要将最大的数字放在堆顶,那么这是一个动态维护最大值的过程,因此我们可以使用大根堆。大根堆的pop()操作即为已经使用的牌。

代码:

#include <bits/stdc++.h>
#define pi acos(-1)
#define int long long
#define PII pair<int,int>
#define all(v) v.begin(),v.end()
#define INF 0x3f3f3f3f3f3f3f3f
#define fs(a) cout<<fixed<<setprecision(a)<< //fs(4)(1.0/3)=0.3333//保留a位小数
#define read() freopen("input.txt","r",stdin)
#define output() freopen("output.txt","w",stdout)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=2e5+10;
const int mod = 1e9+7;
const int Mod = 998244353;
int lowbit(int x){return x&(-x);}
int up(int a,int b){return a<0?a/b:(a+b-1)/b;}//       a/b向上取整
int quickpow(int a,int n){int ans=1;while(n){if(n&1){ans*=a,ans%=Mod;}a*=a;a%=Mod;n>>=1;}return ans;}//快速幂
int qc(int a,int b,int p){int ans=0;while(b){if(b&1){ans+=a,ans%=p;}a*=2;a%=p;b>>=1;}return ans;}//快速乘 a*b%p
int a[N];inline void solve(){int n;cin>>n;priority_queue<int>q;for(int i=1;i<=n;i++) cin>>a[i];int ans=0,cnt=1;while(1){if(cnt>n) break;while(cnt<=n&&a[cnt]!=0) q.push(a[cnt++]);while(cnt<=n&&a[cnt]==0){if(!q.size()){cnt++;continue;}else{ans+=q.top();q.pop();cnt++;}}}cout<<ans<<"\n";
}signed main(){fast;int T;cin>>T;while(T--) solve();
}              

D:思维

题意:给定字符串 s,你可以移除其中两个连续的字母。问操作之后你所能得到的不同字符串的数量是多少

分析:我们发现,如果这样一组字符串:aba,那么删掉两个相邻的元素,所得的结果串是一样的。那么我们可以得出一个结论:如果s[i]==s[i+2],那么就说明有一个重复串的出现。

此外还有一个结论可以从样例得出:如果一个长度为n的串所含的不同字符个数为n,那么可以得到n-1个不同的串。因此,我们只需要减掉重复串的个数即可。

代码:

#include <bits/stdc++.h>
#define pi acos(-1)
#define int long long
#define PII pair<int,int>
#define all(v) v.begin(),v.end()
#define INF 0x3f3f3f3f3f3f3f3f
#define fs(a) cout<<fixed<<setprecision(a)<< //fs(4)(1.0/3)=0.3333//保留a位小数
#define read() freopen("input.txt","r",stdin)
#define output() freopen("output.txt","w",stdout)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=2e5+10;
const int mod = 1e9+7;
const int Mod = 998244353;
int lowbit(int x){return x&(-x);}
int up(int a,int b){return a<0?a/b:(a+b-1)/b;}//       a/b向上取整
int quickpow(int a,int n){int ans=1;while(n){if(n&1){ans*=a,ans%=Mod;}a*=a;a%=Mod;n>>=1;}return ans;}//快速幂
int qc(int a,int b,int p){int ans=0;while(b){if(b&1){ans+=a,ans%=p;}a*=2;a%=p;b>>=1;}return ans;}//快速乘 a*b%p
int a[N];inline void solve(){int n;string s;cin>>n>>s;int ans=0;for(int i=0;i<n-2;i++){if(s[i]==s[i+2]) ans++;}cout<<n-ans-1<<"\n";
}signed main(){fast;int T;cin>>T;while(T--) solve();
}              

 E:思维

题意:给定两个字符串和k,字符串可以将下标 和|i−j|=k和|i−j|=k+1 得两个字符 ,ai,aj 发生交换

分析:通过手撸样例可以发现:如果当n=5,k=3的时候,满足条件的点为:[1,4],[1,5],[2,5]。然后你会发现:点1,2,4,5的位置可以任意交换。位置3则不能交换。所以思路很显然了。

首先判断两个字符串中包含的字符数是否相同,再判断不能交换位置的点上的字符是否相同。

代码:

#include <bits/stdc++.h>
#define pi acos(-1)
#define int long long
#define PII pair<int,int>
#define all(v) v.begin(),v.end()
#define INF 0x3f3f3f3f3f3f3f3f
#define fs(a) cout<<fixed<<setprecision(a)<< //fs(4)(1.0/3)=0.3333//保留a位小数
#define read() freopen("input.txt","r",stdin)
#define output() freopen("output.txt","w",stdout)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=2e5+10;
const int mod = 1e9+7;
const int Mod = 998244353;
int lowbit(int x){return x&(-x);}
int up(int a,int b){return a<0?a/b:(a+b-1)/b;}//       a/b向上取整
int quickpow(int a,int n){int ans=1;while(n){if(n&1){ans*=a,ans%=Mod;}a*=a;a%=Mod;n>>=1;}return ans;}//快速幂
int qc(int a,int b,int p){int ans=0;while(b){if(b&1){ans+=a,ans%=p;}a*=2;a%=p;b>>=1;}return ans;}//快速乘 a*b%pinline bool pd(string a,string b){map<char,int>mp1,mp2;for(int i=0;i<a.size();i++) mp1[a[i]]++;for(int i=0;i<b.size();i++) mp2[b[i]]++;for(auto x:a){if(mp1[x]!=mp2[x]) return false;}return true;
}inline void solve(){int n,k;string s,t;cin>>n>>k>>s>>t;if(!pd(s,t)){cout<<"NO\n";return;}bool ok=true;for(int i=0;i<n;i++){if(i<k&&n-i-1<k&&s[i]!=t[i]){ok=false;break;}}if(ok) cout<<"YES\n";else cout<<"NO\n";
}signed main(){fast;int T;cin>>T;while(T--) solve();
}              

http://www.yayakq.cn/news/472027/

相关文章:

  • 怎么做网站的浏览量济南网站建设认可搜点网络能
  • 成都工业学院文献检索在哪个网站做淘宝数据分析
  • 鲜花网站的数据库建设上海网站备案咨询
  • 百度图在图不留网站方塑料模板厂 塑料模板生产厂家
  • 凡科 360免费建站联想网站建设与分析
  • 襄阳做淘宝网站推广大型网站开发 优帮云
  • vue.js网站如果做自适应wordpress赞助插件
  • xuzhou网站制作网站的简单布局
  • 手机网站与微信结合网页制作软件都有哪些
  • 南通网站建设推广优化市场营销推广方案怎么做
  • 网站建设计划书怎么写深圳商场设计公司排名
  • 网站超链接怎么做 word文档建一个公司需要多少钱?
  • 网站建设公司果动何鹏seo
  • 网站标题怎么隔开网站别人做的收到方正侵权
  • 河北燕郊网站制作房地产市场低迷
  • 怎么样做外贸网站王烨萍
  • 自建设网站公司做网站那个网站好
  • 做政协网站的目的是什么项目合作网站
  • 旅游类网站设计模板下载不会代码建设网站
  • 建设内部网站目的iis7搭建网站
  • 建设一个电商网站需要多少钱做网站最低服务器配置
  • 郑州网站推广价格武清做网站
  • 一 网站开发背景外包网站设计公司
  • 网站建设设计张家界网站建设多少钱
  • 做网站的公司名称网站功能建设流程图
  • 网站设计图网页动态设计怎么做
  • 公司网站注意事项万素网
  • 朝阳住房和城乡建设厅网站上海 高端 网站建设
  • 关于课题网站建设的协议免费网址域名注册
  • 蓝色的包装材料企业网站模板哪些网站可以做店铺推广