이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
bool isPalindrome(string str) {
	for(int i = 0; i <str.length()/2; i++) {
		if(str[i] != str[str.length()-1-i]) {
			return false;
		}
	}
	return true;
}
int findPosition(string array[], string str, int size) {
	for(int i = 0; i < size; i++) {
		if(array[i] == str) {
			return i;
		}
	}
	return -1;
}
void printResults(string a[], int b[], int c[], int maxIndex) {
	for(int i = 0; i <= maxIndex; i++) {
		cout << "substring: " << a[i] << " => no of Occurrence:  " << b[i] 
			<< " => occurrence value: " << c[i] << endl;
	}
}
int arraylength(string str) {
	int len = 0;
	int i = 1;
	while(i <= str.length()) {
		len = len + i;
		i++;
	}
	return len;
}
int findMax(int array[], int maxPos) {
	int max = array[0];
	for(int i = 1; i <= maxPos; i++) {
		if(array[i] > max) {
			max = array[i];
		}
	} 
	return max;	
}
int main() {
	string str;
	cin >> str;
	
	string substr[arraylength(str)];
	int times[arraylength(str)];
	int points[arraylength(str)];
	
	string temp;
	
	int maxIndex = -1;
	
	for(int i = 0; i < str.length(); i++) {
		temp = "";
		for(int k=i; k < str.length(); k++) {
			temp = temp + str[k];
			if(isPalindrome(temp)) {
				int pos = findPosition(substr, temp, sizeof(substr)/sizeof(substr[0]));
				if(pos >= 0) {
					times[pos] = times[pos] + 1;
				} else{
					maxIndex++;
					substr[maxIndex] = temp;
					times[maxIndex] = 1;
					
				}
			}
		}
	}
	
	for(int i = 0; i <= maxIndex; i++) {
		points[i] = substr[i].length() * times[i];
	}
	
	printResults(substr, times, points, maxIndex);
	
	int maxPoints = findMax(points, maxIndex);
		
	cout  << maxPoints;	
}
컴파일 시 표준 에러 (stderr) 메시지
palindrome.cpp: In function 'bool isPalindrome(std::string)':
palindrome.cpp:5:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |  for(int i = 0; i <str.length()/2; i++) {
      |                 ~~^~~~~~~~~~~~~~~
palindrome.cpp: In function 'int arraylength(std::string)':
palindrome.cpp:33:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  while(i <= str.length()) {
      |        ~~^~~~~~~~~~~~~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:64:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |  for(int i = 0; i < str.length(); i++) {
      |                 ~~^~~~~~~~~~~~~~
palindrome.cpp:66:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   for(int k=i; k < str.length(); k++) {
      |                ~~^~~~~~~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |