# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431840 | sikamax2019 | Palindromes (APIO14_palindrome) | C++14 | 1073 ms | 1236 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define _cout(v) for(auto f : v ) cout << f << " " ;
#define _cin(v) for(auto &it : v)cin >> it ;
#define _fo(v) for(int i=0;i<(n);i++)
#define vi vector<int>
#define fs first
#define sc second
int32_t main() {
IOS;
string s;cin>>s;
if(s.length() <= 1) return 1;
int max_len = 1;
int n = s.length();
int st = 0, end = 0;
// Odd length
for(int i = 0; i < n-1; ++i){
int l = i, r = i;
while(l >= 0 && r < n){
if(s[l] == s[r]){
l--; r++;
}else
break;
}
int len = r-l-1;
if(len > max_len){
max_len = len;
st = l+1;
end = r-1;
}
}
// Even length
for(int i = 0; i < n-1; ++i){
int l = i, r = i+1;
while(l >= 0 && r < n){
if(s[l] == s[r]){
l--; r++;
}else
break;
}
int len = r-l-1;
if(len > max_len){
max_len = len;
st = l+1;
end = r-1;
}
}
cout<<max_len;
}
Compilation message (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... |