제출 #994957

#제출 시각아이디문제언어결과실행 시간메모리
994957doducanhPalindromic Partitions (CEOI17_palindromic)C++14
0 / 100
1 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=(p*32)%mod){ left=((left*32)%mod+(s[i]-'a'+1))%mod; right=(right+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; }

컴파일 시 표준 에러 (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...