Task: | Longest palindrome |
Sender: | aalto2024j_004 |
Submission time: | 2024-11-06 16:28:37 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
#4 | TIME LIMIT EXCEEDED | -- | details |
#5 | ACCEPTED | 0.45 s | details |
#6 | ACCEPTED | 0.45 s | details |
#7 | ACCEPTED | 0.04 s | details |
#8 | ACCEPTED | 0.03 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.01 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | TIME LIMIT EXCEEDED | -- | details |
Code
#include <iostream> #include <vector> #include <algorithm> #include <bitset> #include <string> using namespace std; int main() { string s; cin >> s; int n = s.size(); if (n == 0) cout << ""<<endl; int start = 0, maxLen = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= 1; j++) { int ini = i; int end = i + j; while (ini >= 0 && end < n && s[ini] == s[end]) { int currLen = end - ini + 1; if (currLen > maxLen) { start = ini; maxLen = currLen; } ini--; end++; } } } cout << s.substr(start, maxLen) << endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
aaaaaaaaaa |
correct output |
---|
aaaaaaaaaa |
user output |
---|
aaaaaaaaaa |
Test 2
Verdict: ACCEPTED
input |
---|
ababababab |
correct output |
---|
ababababa |
user output |
---|
ababababa |
Test 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
correct output |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
user output |
---|
(empty) |
Test 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
ababababababababababababababab... |
correct output |
---|
ababababababababababababababab... |
user output |
---|
(empty) |
Test 5
Verdict: ACCEPTED
input |
---|
aztdvxzjwxtrludymvpradgbdpgnrq... |
correct output |
---|
aztdvxzjwxtrludymvpradgbdpgnrq... |
user output |
---|
aztdvxzjwxtrludymvpradgbdpgnrq... |
Test 6
Verdict: ACCEPTED
input |
---|
vvfigwwsyxbukedgcfyibvtbclybud... |
correct output |
---|
vvfigwwsyxbukedgcfyibvtbclybud... |
user output |
---|
vvfigwwsyxbukedgcfyibvtbclybud... |
Test 7
Verdict: ACCEPTED
input |
---|
abaabaaaaaaabaababbbbbbabaaabb... |
correct output |
---|
babbbabbbaabbbbaabbbbbbbbaabbb... |
user output |
---|
babbbabbbaabbbbaabbbbbbbbaabbb... |
Test 8
Verdict: ACCEPTED
input |
---|
txolestmgyepwrpofxyesjtsfkhjac... |
correct output |
---|
yxnbaabnxy |
user output |
---|
yxnbaabnxy |
Test 9
Verdict: ACCEPTED
input |
---|
ihpohpzoffel |
correct output |
---|
ff |
user output |
---|
ff |
Test 10
Verdict: ACCEPTED
input |
---|
flexflexvpqxierullgcfckjqflexf... |
correct output |
---|
cfc |
user output |
---|
cfc |
Test 11
Verdict: ACCEPTED
input |
---|
aabbabaabbaababbabaababbaabbab... |
correct output |
---|
abaababbaabbabaababbabaabbaaba... |
user output |
---|
abaababbaabbabaababbabaabbaaba... |
Test 12
Verdict: ACCEPTED
input |
---|
obsession |
correct output |
---|
ses |
user output |
---|
ses |
Test 13
Verdict: ACCEPTED
input |
---|
abcxcbaxcba |
correct output |
---|
abcxcba |
user output |
---|
abcxcba |
Test 14
Verdict: ACCEPTED
input |
---|
zzabc |
correct output |
---|
zz |
user output |
---|
zz |
Test 15
Verdict: ACCEPTED
input |
---|
aaccaabbaaccaaccaabbaaccaa |
correct output |
---|
aaccaabbaaccaaccaabbaaccaa |
user output |
---|
aaccaabbaaccaaccaabbaaccaa |
Test 16
Verdict: TIME LIMIT EXCEEDED
input |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
correct output |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
user output |
---|
(empty) |