| Task: | Palindrome |
| Sender: | rafaykh |
| Submission time: | 2016-10-22 13:35:55 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | details |
| #2 | TIME LIMIT EXCEEDED | -- | details |
| #3 | ACCEPTED | 0.05 s | details |
| #4 | ACCEPTED | 0.04 s | details |
| #5 | TIME LIMIT EXCEEDED | -- | details |
| #6 | TIME LIMIT EXCEEDED | -- | details |
| #7 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:16:55: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int mid = 0; mid + offset < input.length(); mid++) {
^
input/code.cpp:25:61: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (i + i + offset + 1 > largest.length()) {
^Code
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
int main(int argc, char **argv)
{
using namespace std;
ios::sync_with_stdio(0);
string input;
cin >> input;
string largest = "";
// offset is O or 1 for odd, and even sized palindromes.
for (int offset = 0; offset <= 1; offset++) {
for (int mid = 0; mid + offset < input.length(); mid++) {
// max is the space between the mid and the end
int max = input.length() - offset - mid;
// ... unless the mid is closer to the beginning than the end.
max = max > mid ? mid : max;
for (int i = 0; i < max; i++) {
if (input[mid - i] == input[mid + offset + i]) {
if (i + i + offset + 1 > largest.length()) {
largest = input.substr(mid - i, i + i + offset + 1);
}
} else {
break;
}
}
}
}
cout << largest;
}Test details
Test 1
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
| correct output |
|---|
| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
| user output |
|---|
| (empty) |
Test 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| saippuakauppiassaippuakauppias... |
| correct output |
|---|
| saippuakauppiassaippuakauppias... |
| user output |
|---|
| (empty) |
Test 3
Verdict: ACCEPTED
| input |
|---|
| yfsnqpzfxfhdnbozewnjtseeyktblk... |
| correct output |
|---|
| buevzveub |
| user output |
|---|
| buevzveub |
Test 4
Verdict: ACCEPTED
| input |
|---|
| oyyahdsjdwtziuwnmpjhshemvxodtc... |
| correct output |
|---|
| rrfaxafuttsospqnxbwaufpchwjaha... |
| user output |
|---|
| rrfaxafuttsospqnxbwaufpchwjaha... |
Test 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| tcaxtmkrvjovwnhsqquwxuemckkmks... |
| correct output |
|---|
| xtmkrvjovwnhsqquwxuemckkmksqqj... |
| user output |
|---|
| (empty) |
Test 6
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| mwuepokhcaykorctrxqvplhxbxjndd... |
| correct output |
|---|
| eyexbstwynwjbqjasyuaqrmckrgmki... |
| user output |
|---|
| (empty) |
Test 7
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
| correct output |
|---|
| bcbcbcbcbcbcbcbcbcbcbcbcbcbcbc... |
| user output |
|---|
| (empty) |
