Submission #670362

#TimeUsernameProblemLanguageResultExecution timeMemory
670362Mohammad_ParsaPalindromic Partitions (CEOI17_palindromic)C++17
60 / 100
10006 ms2688 KiB
/* in the name of allah */ #include<bits/stdc++.h> using namespace std; #define endl '\n' #define pb push_back #define F first #define S second #define mk make_pair typedef long long ll; const ll N=1e6+7,mod=1e13+3,mab=27; int dp[N]; int main(){ ios:: sync_with_stdio(0),cin.tie(0),cout.tie(0); int q; cin>>q; while(q--){ string s; cin>>s; int k=s.size()/2-1,j=k+1; if(s.size()%2==0){ dp[0]=0; } else{ dp[0]=1;j++; } for(int i=1;i<=s.size()/2;i++){ ll h1=0,h2=0,t=1; dp[i]=1; int g=0; for(int h=0;h<=s.size()/2-1-k;h++){ h1=h1*mab%mod;h1=(h1+s[k+h]-'a')%mod; h2=(h2+(s[j-h]-'a')*t)%mod;t=t*mab%mod; if(h1==h2){ if(dp[i-h-1]+2>dp[i]){ if(g>0) cout<<"F"<<endl; g++; } dp[i]=max(dp[i],dp[i-h-1]+2); } } k--;j++; } cout<<dp[s.size()/2]<<endl; } }

Compilation message (stderr)

palindromic.cpp: In function 'int main()':
palindromic.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for(int i=1;i<=s.size()/2;i++){
      |               ~^~~~~~~~~~~~
palindromic.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    for(int h=0;h<=s.size()/2-1-k;h++){
      |                ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...