# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
447384 | fuad27 | Palindromic Partitions (CEOI17_palindromic) | C++14 | 80 ms | 11796 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
using namespace std;
#define int long long
#define mod (long long)(1e17-3)
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
int32_t main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--) {
string s;
cin >> s;
int ans = 0, n = s.length();
long long hash1 = 0, hash2 = 0, pw = 1, cnt = 0, j = n;
for(int i = 0;i<n/2;i++) {
hash1 = (26*hash1%mod + (s[i] - 'a'))%mod;
hash2 = (hash2+((s[n-i-1]-'a'))*pw%mod)%mod;
if(hash1 == hash2){
hash1 = 0;
hash2 = 0;
ans+=2;
pw = 1;
j = i;
}
else pw=26*pw%mod;
}
if(j!=(n/2)-1 or n%2)ans++;
cout<<ans<<'\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |