답안 #916703

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
916703 2024-01-26T10:18:06 Z vjudge1 Palindromic Partitions (CEOI17_palindromic) C++17
60 / 100
10000 ms 1552 KB
#include <bits/stdc++.h>
using namespace std;

#define sync ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ll logng long

const int m=1e9+7;

int get_hash(const string &s){
    int pw=1,hs=0;
    for(char c:s){
        hs=(hs+(1ll*(c-'a'+1)*pw))%m;
        pw=(pw*29)%m;
    }
    return hs;
}

int main(){
    sync;
    string s;
    int t;
    cin>>t;
    while(t--){
        cin>>s;
        int cnt=1,n=s.size(),l=0,r=n-1,d=n/2;
        while(r>=d && l<r){
            if(s[r]==s[l] && get_hash(s.substr(l,n-r))==get_hash(s.substr(r,n-r))){
                cnt+=2;
                l+=n-r;
                n=r;
                if (r==d)cnt--;
            }
            r--;
        }
        cout<<cnt<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 223 ms 520 KB Output is correct
11 Correct 226 ms 596 KB Output is correct
12 Correct 17 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 223 ms 520 KB Output is correct
11 Correct 226 ms 596 KB Output is correct
12 Correct 17 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Execution timed out 10010 ms 1552 KB Time limit exceeded
15 Halted 0 ms 0 KB -