답안 #710287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710287 2023-03-15T06:40:28 Z ktkerem Palindromic Partitions (CEOI17_palindromic) C++17
100 / 100
251 ms 11148 KB
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define llll std::pair<ll , ll>
#define pb push_back
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
#define debug std::cout << "!!ALERT ALERT!!" << std::endl;
const ll limit = 1e9+7;
const ll sus = 1e5 + 5;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a , ll b){
    return (rng() % (b-a+1)) + a;
}
/*global variables*/
ll n;std::string h;
ll t = 1;
/**/
/*functions*/
ll binpow(ll x , ll y){
    ll g = 1;
    while(y){
        if(y & 1){
            g*=x;
            g%=limit;
        }
        x*=x;
        x%=limit;y/=2;
    }
    return g;
}
/**/
void solve(){
    std::cin >> h;
    n = h.size();
    ll fo = 0 ,so = 0;
    ll l = 0 , r = n-1;
    ll ls = 1;
    ll ans = 1;
    std::string ff , ss;
    while(r > l){
        fo = ((fo * 31) + (h[l] - 'a' + 1))%limit;
        so = (so + ((binpow(31 , ls - 1) * (h[r] - 'a' + 1)) % limit))%limit;
        if(fo == so){
            if(r-1 == l){
                ans--;
            }
            ans+=2;
            fo = 0;so = 0;
            ls = 0;
        }
        r--;l++;
        ls++;
    }
    std::cout << ans;
    if(t != 0){
        std::cout << std::endl;
    }
    return;/**/
}
int main(){
    std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE
        freopen("in.txt" , "r" , stdin);
        freopen("out.txt" , "w" , stdout);
    #endif*/
    std::cin >> t;
    while(t--){
        solve();
    }
}

Compilation message

palindromic.cpp:5:78: warning: "/*" within comment [-Wcomment]
    5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 352 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 352 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 206 ms 11148 KB Output is correct
15 Correct 227 ms 6532 KB Output is correct
16 Correct 251 ms 10648 KB Output is correct
17 Correct 32 ms 6072 KB Output is correct