제출 #1150290

#제출 시각아이디문제언어결과실행 시간메모리
1150290dostsPalindromic Partitions (CEOI17_palindromic)C++20
60 / 100
10091 ms3624 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;
    bool finito = 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;
                if (ptr == ptr2-1) finito = 1;
                ptr++,ptr2--;
                found = 1;
                break;
            }
        }
        if (!found) break;
    }
    if (!finito) 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...