# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
471965 | malar | Palindromes (APIO14_palindrome) | C++14 | 1090 ms | 131076 KiB |
이 제출은 이전 버전의 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 sub, int size) {
for(int i = 0; i < size; i++) {
if(array[i] == sub) {
return i;
}
}
return -1;
}
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[str.length()];
int times[str.length()];
int points[str.length()];
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, maxIndex);
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];
}
cout << findMax(points, maxIndex);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |