Submission #1150289

#TimeUsernameProblemLanguageResultExecution timeMemory
1150289dostsPalindromic Partitions (CEOI17_palindromic)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3,unroll-loops") using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define all(cont) cont.begin(),cont.end() #define vi vector<int> const int inf = 1e17,N = 2e6+1,MOD = 1e9+7,BL = 1000; void solve() { string s; cin >> s; int n = s.size(); int ptr = 1,ptr2 = n; int ans = 0; while (1) { string a = "",b = ""; bool found = 0; for (;ptr < ptr2;ptr++,ptr2--) { a+=s[ptr-1]; b+=s[ptr2-1]; string c = b; reverse(all(c)); if (c == a) { ans+=2; ptr++,ptr2--; found = 1; break; } } if (!found) break; } if (ptr >= ptr2) ans++; cout << ans << '\n'; } int32_t main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #ifdef Dodi freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t = 1; cin >> t; while (t --> 0) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...