# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3584 | waps12b | Make superpalindrome! (kriii1_M) | C++98 | 4 ms | 2088 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<string>
#include<iostream>
using namespace std;
string make(string s){
if(s.length() == 1) return s;
int len = s.length();
bool sw= false;
for(int i=0;i<(len+1)/2;i++){
char &l = s[i];
char &r = s[len - i - 1];
if(sw)
r = l = 'a';
if( r > l ){
sw = true;
r = ++l;
}else{
r = l;
}
}
string ans = make(s.substr(0,len/2));
if( len % 2 == 0)
return ans + ans;
else
return ans + s[len/2] + ans;
}
int main(){
string s;
cin >> s ;
cout << make(s) << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |