您的位置:首页 > 游戏 > 手游 > codeforces 1742F

codeforces 1742F

2024/10/8 12:45:57 来源:https://blog.csdn.net/weixin_70831807/article/details/140731424  浏览:    关键词:codeforces 1742F

题目链接

题目大意

给定两个初始均只含一个 a a a的字符串 s , t s,t s,t,给定 q q q次操作,有两种操作

  • 1 k x,表示在 s s s串后面加 k k k x x x
  • 2 k x,表示在 t t t串后面加 k k k x x x
    对于每次操作完成后,输出是否可能将 s , t s,t s,t按任意指定顺序重排后, s s s串严格小于 t t t

思路

注意到我们可以按任意顺序重排
t t t只要不是纯 a a a为必胜态(因为永远可以把一个非 a a a放到 t t t第一位而把 a a a放到 s s s第一位)
t , s t,s t,s均为纯 a a a,比较长度
t t t为纯 a a a s s s不为,则必败态

ACcode

#include<bits/stdc++.h>using namespace std;#define int long longvoid solve()
{int q;cin>>q;int len1=1,len2=1;bool f1=1,f2=1;//t是否为纯awhile(q--){int d,k;cin>>d>>k;string str;cin>>str;bool flag=0;for(auto x:str)if(x!='a'){flag=1;break;}if(d==1){len1+=str.size()*k;if(flag)f1=0;}if(d==2){len2+=str.size()*k;if(flag)f2=0;}if(!f2)cout<<"YES"<<'\n';else if(f2&&!f1)cout<<"NO"<<'\n';else{if(len2>len1)cout<<"YES"<<'\n';else cout<<"NO"<<'\n';}}
}signed main()
{ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int t;cin>>t;while(t--){solve();}return 0;
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com