Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3578 | 孙浚轩 | 字符串展开 | C++ | Wrong Answer | 0 MS | 268 KB | 1651 | 2024-06-15 16:46:17 |
#include<iostream> using namespace std; string unfold(char begin,char end,int p1,int p2,int p3,int &lens,int &cv){ string str; str+=begin++; if(end-begin>1){ if(p1<=2){ if(begin>='a'&&begin<='z'&&end>='a'&&end<='z'){ int index=0; if(p1==2) index=32; if(p3==1) for(;begin<end;begin++){ for(int i=0;i<p2;i++) str+=begin-index,lens++,cv++; }else{ int temp=end-1; for(;temp>=begin;temp--){ for(int i=0;i<p2;i++) str+=temp-index,lens++,cv++; } } }else{ if(p3==1) for(;begin<end;begin++){ for(int i=0;i<p2;i++) str+=begin,lens++,cv++; }else{ int temp=end-1; for(;temp>=begin;temp--){ for(int i=0;i<p2;i++) str+=temp,lens++,cv++; } } } }else{ int frequency=(end-begin-1)*p2; for(int i=0;i<frequency;i++) str+='*',lens++,cv++; } } str+=end; return str; } int main(){ string s; int p1,p2,p3; cin>>p1>>p2>>p3>>s; int lens=s.size(); for(int i=1;i<lens-1;i++){ if(s[i]=='-') if(s[i-1]<s[i+1]) if(s[i-1]>='a'&&s[i-1]<='z'&&s[i+1]>='a'&&s[i+1]<='z'||s[i-1]>='1'&&s[i-1]<='9'&&s[i+1]>='1'&&s[i+1]<='9') s.replace(i-1,3,unfold(s[i-1],s[i+1],p1,p2,p3,lens,i)); } cout<<s; return 0; }
------Input------
1 2 1 abcs-w1234-9s-4zz
------Answer-----
abcsttuuvvw1234556677889s-4zz
------Your output-----
abcs-w123sttuuvvws-4zz