Submission #3617

# Submission time Handle Problem Language Result Execution time Memory
3617 2013-08-31T07:00:54 Z waps12b Make superpalindrome! (kriii1_M) C++
Compilation error
0 ms 0 KB
#include<string>
#include<iostream>
using namespace std;




//s보다 사전순 같거나 앞에 있으면서 슈퍼팰린드롬
string make(string s){
	//1인 경우는 볼 필요 없다.
	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( l < r )
			sw = true;
		r = l;
	}
	if(sw){
		for(int i= (len+1)/2 -1; i>=0; i--){
			char &l = s[i];
			char &r = s[len - i - 1];
			if( l != 'z'){
				r = ++l;
				break;
			}
			l = r = 'a';
		}
	}
	string ans = make(s.substr(0,len/2));
	string ar = ans;
	reverse(ar.begin(),ar.end());
	if(len&1){
		if(ans > s.substr(0,len/2)){
			s[(len)/2] = 'a';
		}
		return ans + s[(len)/2] + ar;
	}
	return ans + ar;
}

int main(){
	string s;
	cin >> s ;
	cout << make(s) << endl;
	return 0;
}

Compilation message

M.cpp: In function 'std::string make(std::string)':
M.cpp:34:29: error: 'reverse' was not declared in this scope