Submission #670396

#TimeUsernameProblemLanguageResultExecution timeMemory
670396nolimiyaPalindromic Partitions (CEOI17_palindromic)C++17
0 / 100
33 ms70736 KiB
#include <bits/stdc++.h> #include <math.h> //in the name of god,aka allah //**gray sety orz** #pragma GCC optimize("unroll-loops") using namespace std; #define pi pair<long long , long long> #define pii pair<long long , pair<long long , long long>> const int maxm =1e6 + 5; long long aval = 27; const long long mod = 1e13 + 3 ; typedef long long ll; ll l,r,mid; ll n,m; ll dis[maxm] , sum[maxm]; bool isval(int mid){ //cout << mid <<" " << mid*mid-mid <<endl; if (((mid-1)*mid)/2 < m) return 0; return 1; } int darage[maxm] , ss , mm; queue<int> q; vector<pi> g[maxm] , z[maxm]; ll sath[maxm]; bool vis[maxm] , gos[maxm]; int pedaret[maxm]; ll get_par(ll v){ if (pedaret[v]==v) return v; return pedaret[v] = get_par(pedaret[v]); } void merge(ll r , ll q){ if (get_par(r)!=get_par(q))l+=max(darage[r],darage[q])*1ll*sath[r]*1ll*sath[q]; r = get_par(r) , q = get_par(q); if (r!=q){ if (sath[r]<sath[q]) swap(r,q); pedaret[q] = r; sath[r] += sath[q]; } return ; } ll pars1[maxm] , pars2[maxm]; vector<ll> se[maxm]; set<pi> st; int rp[maxm]; pi w[maxm]; int dp[maxm]; //ll rw[maxm][maxm]; map<ll,ll> mp; void solve(){ string s; cin >>s; l = 0 , r = 0 , mid = 0 , ss = 1; n = s.size(); for (int i=0; i<=n/2-1; i++){ l=(l*aval)%mod; l=( l + s[i]-'a'+1) % mod; r = (r+(s[n-1-i]-'a'+1)*ss)%mod; ss = (ss*aval)%mod; if (l==r) mid+=2 , ss = 1 , l = 0 , r = 0; } if (l||n%2) mid++; cout<<mid<<endl; } int main() { ios::sync_with_stdio (0), cin.tie (0), cout.tie (0); int t; cin >>t; while (t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...