이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 =1e2 + 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,ss=1;
n=s.size();
mid=0;
for(int h=0;h<=n/2-1;h++){
l=l*aval%mod;
l=(l+s[h]-'a'+1)%mod;
r=(r+(s[n-1-h]-'a'+1)*ss)%mod;
ss=ss*aval%mod;
if(l==r) mid+=2 , ss=1,l=0,r=0;
}
if(l!=0 || s.size()%2==1)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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |