Submission #217847

#TimeUsernameProblemLanguageResultExecution timeMemory
217847aloo123Palindromic Partitions (CEOI17_palindromic)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define mp make_pair #define pb push_back #define vll vector<ll> #define endl "\n" #define pll pair<ll,ll> #define all(x) (x).begin() , (x).end() #define f first #define s second using namespace std; const ll N =(2e5+5); const ll MOD = 998244353; const ll INF = 1e16; const ll LOG = 25; long long binpow(long long a, long long b) { a %= MOD; long long res = 1; while (b > 0) { if (b & 1) res = (res * a)%MOD ; a = (a * a)%MOD ; b >>= 1; } res%=MOD; return res; } void solve(){ string s; cin>>s; ll n = (ll)s.size(); //cout<<n<<endl; ll l= 0,r= n -1; string a; string b; ll ans = 0; ll x,y; while(l < r){ a+=s[l]; b+=s[r]; string c =b;reverse(all(c)); if(c == a){ ans += 2; a=""; b=""; x = l,y =r; // cout<<l<<" "<<r<<endl; } l++,r--; } // for(int i = x+1;i<y;i++)cout<<s[i];cout<<endl; // cout<<l<<" "<<r<<endl; if((x+1)<=(y-1)) ans++; cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); ll t;cin>>t; while(t--){ solve(); } return 0; }

Compilation message (stderr)

palindromic.cpp: In function 'void solve()':
palindromic.cpp:58:17: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if((x+1)<=(y-1))
               ~~^~~
palindromic.cpp:58:5: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if((x+1)<=(y-1))
     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...