[Codeforces Round 855 (Div. 3)](https://codeforces.com/contest/1800)
1.Codeforces Round 909 (Div. 3)2.Codeforces Round 910 (Div. 2)3.Codeforces Round 912 (Div. 2)4.Educational Codeforces Round 158 (Rated for Div. 2)5.Codeforces Round 911 (Div. 2)6.[Educational Codeforces Round 159 (Rated for Div. 2)](https://codeforces.com/contest/1902)
7.[Codeforces Round 855 (Div. 3)](https://codeforces.com/contest/1800)
8.Codeforces Round 913 (Div. 3)9.Codeforces Round 904 (Div. 2)10.Codeforces Round 914 (Div. 2)11.Codeforces Round 917 (Div. 2)12.Codeforces [Hello 2024]13.Codeforces Round 919 (Div. 2)14.Codeforces Round 920 (Div. 3)Codeforces Round 855 (Div. 3)
A. Is It a Cat?
为什么这个A这么麻烦
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
int n;
string s;
cin>>n>>s;
s = " " + s;
int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
for(int i=1;i<=n;i++){
if(s[i]=='m'||s[i]=='M'){
cnt1++;
if(cnt2+cnt3+cnt4>0){
cout<<"NO"<<endl;
return;
}
}else if(s[i]=='e'||s[i]=='E'){
cnt2++;
if(cnt3+cnt4>0){
cout<<"NO"<<endl;
return;
}
}else if(s[i]=='o'||s[i]=='O'){
cnt3++;
if(cnt4){
cout<<"NO"<<endl;
return;
}
}else if(s[i]=='w'||s[i]=='W'){
cnt4++;
}else{
cout<<"NO"<<endl;
return;
}
}
if(!cnt1||!cnt2||!cnt3||!cnt4){
cout<<"NO"<<endl;
return;
}
cout<<"YES"<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
return 0;
}
B. Count the Number of Pairs
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
int n,k;
string s;
cin>>n>>k>>s;
map<int,int> cnt;
for(int i=0;i<n;i++)
cnt[s[i]]++;
int ans=0;
int x=0;
for(int i='A';i<='Z';i++){
int y=min(cnt[i],cnt[i+'a'-'A']);
ans += y;
x = max(cnt[i],cnt[i+'a'-'A'])-y;
if(k >= x/2){
ans+=x/2;
k -=x/2;
}else{
ans+=k;
k=0;
}
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
return 0;
}
C1\2. Powering the Hero
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
priority_queue<int,vector<int>,less<int>> path;
int n;
cin>>n;
int ans=0;
for(int i=1;i<=n;i++){
int x;
cin>>x;
if(x==0){
if(path.size()){
ans+=path.top();
path.pop();
}
}else path.push(x);
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
return 0;
}
D. Remove Two Letters
刚开始开map写了个暴力,结果mle了。
要注意一下,如果s[i-1]==s[i+1]那么就一定会有一次重复。
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 2e5 + 10;
void solve(){
int n;
string s;
cin>>n>>s;
int cnt=0;
for(int i=1;i<s.size()-1;i++)
if(s[i-1]==s[i+1]) cnt++;
cout<<n-1-cnt<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
return 0;
}
E1\2. Unforgivable Curse
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
int n,k;
string s,t;
cin>>n>>k;
cin>>s>>t;
s = " " + s;
t = " " + t;
vector<int> cnt1(26,0),cnt2(26,0);
for(int i=1;i<=n;i++){
if(i-k<1&&i+k>n)
{
if(s[i]!=t[i])
{
cout<<"NO"<<endl;
return;
}
}
else
{
cnt1[s[i]-'a']++;
cnt2[t[i]-'a']++;
}
}
for(int i=0;i<26;i++)
{
if(cnt1[i]!=cnt2[i])
{
cout<<"NO"<<endl;
return;
}
}
cout<<"YES"<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
return 0;
}
F. Dasha and Nightmares
#include <bits/stdc++.h>
//#define int long long
#define endl '\n'
using namespace std;
const int N = 2e5 + 10;
string s;
int a[N] , b[N] ,cnt[1<<26];
int x[26];
void solve(){
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>s;
for(int j=0;j<s.size();j++)
{
a[i] |= (1<<(s[j]-'a'));
b[i] ^= (1<<(s[j]-'a'));
}
}
long long ans=0;
for(int j=0;j<26;j++)
{
int target = (1<<26) - 1 - (1<<j);
for(int i=1;i<=n;i++)
{
if(a[i]>>j & 1) continue;
cnt[b[i]]++;
ans += cnt[b[i]^target];
//cout<<ans<<endl;
}
for(int i=1;i<=n;i++){
if(a[i]>>j & 1) continue;
cnt[b[i]]--;
}
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
//cin>>T;
while(T--) solve();
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧