답안 #1095059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1095059 2024-10-01T08:11:33 Z vjudge1 Palindromic Partitions (CEOI17_palindromic) C++17
60 / 100
10 ms 10172 KB
#include<bits/stdc++.h>
using namespace std;
#define task "paltext"
#define fi first
#define se second
#define int long long
#define ii pair<int,int>
#define ld double
#define mp make_pair
#define lg2 21
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define fii fi.fi
#define fis fi.se
#define sfi se.fi
#define see se.se
#define base 31
int dx[]={0LL,0LL,1,-1,1,1,-1,-1};
int dy[]={1,-1,0LL,0LL,1,-1,1,-1};
const int maxn=4e5+1;
const int maxa=5*maxn;
const int mod=998244353;
const int maxi=1000;
string s;
int n,pw[maxn],hs[maxn];
int geth(int l,int r)
{
    return (hs[r]-hs[l-1]*pw[r-l+1]+mod*mod)%mod;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(task".inp","r")){
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);}
    int t;
    cin>>t;
    while(t--){
    cin>>s;
    n=s.size();
    s=' '+s;
    pw[0]=1;
    for(int i=1;i<=n;i++)
    {
        pw[i]=(pw[i-1]*base)%mod;
    }
    for(int i=1;i<=n;i++)
    {
        hs[i]=(hs[i-1]*base+s[i]-'a'+1)%mod;
    }
    int last=1;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(geth(last,i)==geth(n-i+1,n-last+1))
        {
            ans++;
            last=i+1;
        }
    }
    cout<<ans<<'\n';
    }
}

Compilation message

palindromic.cpp: In function 'int main()':
palindromic.cpp:34:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
palindromic.cpp:35:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     freopen(task".out","w",stdout);}
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 856 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 856 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 684 KB Output is correct
14 Runtime error 10 ms 10172 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -