比赛 |
练习赛 |
评测结果 |
AAAAAAAAAA |
题目名称 |
字符串的展开 |
最终得分 |
100 |
用户昵称 |
氢氦 |
运行时间 |
0.005 s |
代码语言 |
C++ |
内存使用 |
13.66 MiB |
提交时间 |
2019-05-21 20:29:34 |
显示代码纯文本
// luogu-judger-enable-o2
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int p1,p2,p3;
string x,ans;
int main()
{
freopen("expand.in","r",stdin);
freopen("expand.out","w",stdout);
cin>>p1>>p2>>p3;
cin>>x;
int len=x.length();
for(int i=0;i<len;i++){
if(x[i]!='-')ans+=x[i];
if(x[i]=='-'&&x[i+1]=='-'){
ans+=x[i],ans+=x[i+1];
i++;continue;
}
if(i==0&&x[i]=='-'){
ans+=x[i];continue;
}
else if(x[i]=='-'){
if(x[i-1]+1==x[i+1]){
ans+=x[i+1],i++;
continue;
}
if((int)(x[i-1])+1>=(int)(x[i+1])){
ans+=x[i]; continue;
}
if((isdigit(x[i-1])&&isalpha(x[i+1]))||(isdigit(x[i+1])&&isalpha(x[i-1]))){
ans+=x[i];continue;
}
else{
if(p3==1){
int a=int(x[i-1]),b=int(x[i+1]);
for(int i=a+1;i<=b-1;i++){
for(int j=1;j<=p2;j++){
if(p1==1)ans+=tolower(char(i));
else if(p1==2)ans+=toupper(char(i));
else ans+="*";
}
}
//cout<<int(x[i-1])<<' '<<int(x[i+1]);
}
if(p3==2){
int a=int(x[i+1]),b=int(x[i-1]);
for(int i=a-1;i>=b+1;i--){
for(int j=1;j<=p2;j++){
if(p1==1)ans+=tolower(char(i));
else if(p1==2)ans+=toupper(char(i));
else ans+="*";
}
}
}
}
}
}
cout<<ans<<'\n';
return 0;
}