제출 #482878

#제출 시각아이디문제언어결과실행 시간메모리
482878MohamedAliSaidanePalindromic Partitions (CEOI17_palindromic)C++14
0 / 100
0 ms204 KiB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> ti;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ld,ld> pld;
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front
#define ff first
#define ss second
#define MOD (ll)(1000000007)
#define INF (ll) (1e18)
#define all(v) (v).begin(),(v).end()
const int nx[8] = {0, 0, 1, -1,1,1,-1,-1}, ny[8] = {1, -1, 0, 0,1,-1,1,-1}; //East, West, South, North+
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;}

////////////******SOLUTION******\\\\\\\\\\\

string s, t;
int n;

void solve()
{
    cin >> s;
    n = s.length();
    t = s;
    reverse(all(t));
    int ans = 0;
    int i = 0;
    while(i <= n/2-1 + n%2)
    {
        if(s[i] != s[n-i-1])
        {
            int debut = 1;
            int fin = n/2-i-1+n%2;
            int rep = n/2-i+n%2;
            while(debut <= fin)
            {
                int mid = (debut+fin)/2;
                bool flag= true;
                for(int j = 0; j <= mid; j ++)
                {
                    if(s[i+j] != s[n-i-mid+j-1])
                    {
                        flag = false;
                        break;
                    }
                }
                if(flag)
                {
                    rep = mid;
                    fin = mid - 1;
                }
                else
                    debut = mid +1;
            }
            i += rep;
        }
        ans += 2;
        if(i >= n/2)
            ans --;
        i ++;
    }
    cout << ans << '\n';
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tt; cin >> tt;
    while(tt--)
        solve();
}

컴파일 시 표준 에러 (stderr) 메시지

palindromic.cpp:24:1: warning: multi-line comment [-Wcomment]
   24 | ////////////******SOLUTION******\\\\\\\\\\\
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...