Submission #45588316
Source Code Expand
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,s,e) for(ll i=s;i<=e;++i)
#define FFOR(i,s,e) for(ll i=s;i>=e;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define ALL(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define vl vector<ll>
#define vs vector<string>
#define so(a) sort(a.begin(),a.end())
#define fi first
#define se second
#define print(a) cout<<a<<endl
#define ssize(a) (ll)(a.size())
#define MAX_N 1002
#define i197 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1000000000000000001;
struct edge
{
int to, cost;
};
struct pos{
// 1 変数を入れる;
ll t;
ll x,y;
set<ll> st;
};
int dx[4] = { 1, 0, -1, 0};
int dy[4] = { 0, 1, 0, -1};
int dd[5] = { 0, 1, 0, -1, 0};
typedef pair<ll, ll> P2;
typedef pair<pair<ll,ll>,ll> P3;
typedef pair<string,ll> Ps;
typedef pair<pair<ll,ll>,pair<ll,ll> > P4;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
string s;
cin>>s;
ll ans=0;
rep(i,ssize(s)){
FOR(j,i,ssize(s)-1){
ll f=0;
rep(k,ssize(s)){
if(i+k>j-k)break;
if(s[i+k]!=s[j-k])f=1;
}
if(!f)chmax(ans,j-i+1);
}
}
print(ans);
return 0;
}
Submission Info
| Submission Time |
|
| Task |
B - Longest Palindrome |
| User |
akarinkof |
| Language |
C++ 20 (gcc 12.2) |
| Score |
200 |
| Code Size |
1564 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3636 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
200 / 200 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample00.txt, sample01.txt, sample02.txt |
| All |
sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt |
| Case Name |
Status |
Exec Time |
Memory |
| sample00.txt |
AC |
1 ms |
3568 KiB |
| sample01.txt |
AC |
1 ms |
3496 KiB |
| sample02.txt |
AC |
1 ms |
3504 KiB |
| testcase00.txt |
AC |
1 ms |
3432 KiB |
| testcase01.txt |
AC |
1 ms |
3468 KiB |
| testcase02.txt |
AC |
1 ms |
3580 KiB |
| testcase03.txt |
AC |
1 ms |
3452 KiB |
| testcase04.txt |
AC |
1 ms |
3636 KiB |
| testcase05.txt |
AC |
1 ms |
3328 KiB |
| testcase06.txt |
AC |
1 ms |
3476 KiB |
| testcase07.txt |
AC |
1 ms |
3508 KiB |
| testcase08.txt |
AC |
1 ms |
3428 KiB |
| testcase09.txt |
AC |
1 ms |
3500 KiB |
| testcase10.txt |
AC |
1 ms |
3568 KiB |
| testcase11.txt |
AC |
1 ms |
3504 KiB |
| testcase12.txt |
AC |
1 ms |
3636 KiB |
| testcase13.txt |
AC |
1 ms |
3440 KiB |
| testcase14.txt |
AC |
1 ms |
3568 KiB |
| testcase15.txt |
AC |
1 ms |
3456 KiB |
| testcase16.txt |
AC |
1 ms |
3504 KiB |
| testcase17.txt |
AC |
1 ms |
3580 KiB |
| testcase18.txt |
AC |
1 ms |
3444 KiB |
| testcase19.txt |
AC |
1 ms |
3372 KiB |