# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
543249 | 2022-03-30T00:54:30 Z | Olympia | Palindromic Partitions (CEOI17_palindromic) | C++17 | 385 ms | 12196 KB |
#include <vector> #include <iostream> #include <cassert> #include <cmath> #include <set> #include <map> #include <stack> #include <queue> #include <set> #include <algorithm> #include <iomanip> #define ll long long using namespace std; const int MOD = 1e9 + 7; ll binPow (ll x, ll y) { ll ans = 1; ll res = x; while (y > 0) { if (y & 1) { ans *= res; ans %= MOD; } res *= res; res %= MOD; y >>= 1; } return ans; } void solve() { string s; cin >> s; ll l = 0; ll r = 0; ll len = 0; int cnt = 0; for (int i = 0; i < s.length()/2; i++) { l += (binPow(10, len) * (s[i] - 'a')) % MOD; r = ((10 * r) % MOD + (s[s.length() - i -1 ] - 'a')) % MOD; l %= MOD, r %= MOD; len++; if (l == r) { cnt += 2; l = r = len = 0; } else if (s.length() % 2 == 0 && i == s.length()/2 - 1) { cnt++; } } if (s.length() % 2 == 1) { cnt++; } cout << cnt << endl; } int main() { int t; cin >> t; while(t--) { solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 296 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 272 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 296 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 272 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 296 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 272 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 4 ms | 340 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 340 KB | Output is correct |
13 | Correct | 3 ms | 316 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 296 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 272 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 4 ms | 340 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 340 KB | Output is correct |
13 | Correct | 3 ms | 316 KB | Output is correct |
14 | Correct | 383 ms | 12196 KB | Output is correct |
15 | Correct | 294 ms | 7276 KB | Output is correct |
16 | Correct | 385 ms | 11488 KB | Output is correct |
17 | Correct | 127 ms | 6888 KB | Output is correct |