RC-u1 睿抗,启动!
写了半个多小时,差一分。鉴定为nt模拟。
#include<bits/stdc++.h>
using ll=long long;
using ull=unsigned long long;
using PII=std::pair<double,double>;
using ari=std::array<int,3>;
#define fir first
#define sec second
const int N=2e5+10,P=131,mu=360360;
std::string s;
void solve()
{
for(auto &i:s)
{
if(std::isupper(i))
{
i=(i-'A'+1)%26+'A';
}else if(std::islower(i)){
i=(i-'a'-1+26)%26+'a';
}
}
int f1=0,f2=0;
for(int i=0;i<s.length();i++)
{
if(std::islower(s[i]))
{
if(f1!=0){//如果上一个也是小写
f1++;
}else{
if(f2>=3)//大写超过3个了
{
for(int j=i-f2;j<i;j++)
{
s[j]=std::tolower(s[j]);
}
}
f2=0,f1=1;
}
}else if(std::isupper(s[i])){
if(f2!=0){
f2++;
}else{
if(f1>=3)
{
for(int j=i-f1;j<i;j++)
{
s[j]=std::toupper(s[j]);
}
}
f1=0,f2=1;
}
}else{
if(f2>=3)//大写超过3个了
{
for(int j=i-f2;j<i;j++)
{
s[j]=std::tolower(s[j]);
}
}
if(f1>=3)
{
for(int j=i-f1;j<i;j++)
{
s[j]=std::toupper(s[j]);
}
}
f1=0,f2=0;
}
//std::cout<<i<<" "<<f1<<" "<<f2<<'\n';
}
int l=(int)s.length()-1;
if(f2>=3)//大写超过3个了
{
for(int j=l-f2+1;j<=l;j++)
{
s[j]=std::tolower(s[j]);
}
}
if(f1>=3)
{
for(int j=l-f1+1;j<=l;j++)
{
s[j]=std::toupper(s[j]);
}
}
}
signed main()
{
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int t=1;
std::cin>>t;
std::cin>>s;
std::cout<<s<<'\n';
while(t--)
{
solve();
}
std::cout<<s<<'\n';
return 0;
}