Submission #994962

#TimeUsernameProblemLanguageResultExecution timeMemory
994962doducanhPalindromic Partitions (CEOI17_palindromic)C++14
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int mod=(1ll<<61)-1; const int maxn=1e6+7; //int p[maxn]; //int h[maxn]; string s; int t; //int get(int l,int r) //{ // return (h[r]-(h[l-1]*p[r-l+1]%mod)+mod)%mod; //} void sol() { cin>>s; int n=s.size(); s=" "+s; int found=0; int start=1; int ans=0; while(found!=-1){ int left=0; int right=0; found=-1; for(int i=start,p=1;i<=n/2;i++,p=(1ll*p*32)%mod){ left=(1ll*(left*32)%mod+(s[i]-'a'+1))%mod; right=(right+1ll*p*(s[n-i+1]-'a'+1)%mod)%mod; // cout<<left<<" "<<right<<" "<<s[i]<<"\n"; if(left==right){ found=i; start=found+1; break; } } if(found!=-1){ ans+=2; } } if((start-1)*2==n)cout<<ans<<"\n"; else cout<<ans+1<<"\n"; } main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>t; while(t--){ sol(); } return 0; }

Compilation message (stderr)

palindromic.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...