제출 #1268965

#제출 시각아이디문제언어결과실행 시간메모리
1268965EntityPlanttPalindromic Partitions (CEOI17_palindromic)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; const int64_t mod = (srand(time(0)), (int64_t(rand()) << 29) + rand()); constexpr int B = 29; void solve() { string s; cin >> s; int64_t hf = 0, hb = 0, pow = 1; int c = 0; #pragma GCC ivdep for (char &c : s) c -= 96; for (int i = 0; i < s.size() >> 1; i++) { hf = (hf * B % mod + s[i]) % mod; hb = (hb + pow * s[s.size() - i - 1] % mod) % mod; pow = pow * B % mod; if (hf == hb) { ++c; hf = hb = 0; pow = 1; } } cout << 2 * c + (s.size() & 1 || hf) << '\n'; } signed 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...