Submission #1103893

#TimeUsernameProblemLanguageResultExecution timeMemory
1103893ezzzayPalindromic Partitions (CEOI17_palindromic)C++14
100 / 100
169 ms10800 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back vector<int>ans; void fun(){ string s; cin>>s; int n=s.size(); int a=0,b=0; int x=-1; int p=0; int k=1; int m=1e9+7; int mlt=1; for(int i=0;i<n/2;i++){ a= a*(31)+(s[i]); a%=m; b=(s[n-i-1])*mlt+b; b%=m; mlt*=31; mlt%=m; if(a==b){ x=i; a=0,b=0; k=1; p+=2; mlt=1; } //cout<<a<<" "<<b<<endl; } if(n%2 or x<n/2-1)p++; ans.pb(p); } signed main(){ int t; cin>>t; while(t--)fun(); for(auto a:ans)cout<<a<<endl; }

Compilation message (stderr)

palindromic.cpp: In function 'void fun()':
palindromic.cpp:15:9: warning: variable 'k' set but not used [-Wunused-but-set-variable]
   15 |     int k=1;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...