# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169453 | 2019-12-20T12:17:05 Z | Ruxandra985 | Palindromic Partitions (CEOI17_palindromic) | C++14 | 52 ms | 11144 KB |
#include <bits/stdc++.h> #define MOD 1000000007 #define DIM 1000010 using namespace std; char s[DIM]; int main() { FILE *fin = stdin; FILE *fout = stdout; int t , n, l , r , sol , nr; long long prod , prefix , suffix; fscanf (fin,"%d\n",&t); for (;t;t--){ fgets (s+1 , 1000010 , fin); n = 0; while ('a' <= s[n+1] && s[n+1] <= 'z') n++; l = 1; r = n; prefix = suffix = 0; prod = 1; sol = 0; nr = 0; while (l < r){ prefix = ( prefix * ('z' - 'a') + (s[l] - 'a') )%MOD; suffix = ( ( s[r] - 'a' ) * prod + suffix )%MOD; prod = (prod * ('z' - 'a'))%MOD; nr++; if (prefix == suffix){ sol+=2; prefix = 0; suffix = 0; prod = 1; nr = 0; } l++; r--; } if ( l == r || nr != 0 ) sol++; fprintf (fout,"%d\n" , sol); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 252 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 252 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 504 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 252 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 504 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 50 ms | 11144 KB | Output is correct |
15 | Correct | 30 ms | 6432 KB | Output is correct |
16 | Correct | 52 ms | 10560 KB | Output is correct |
17 | Correct | 26 ms | 6008 KB | Output is correct |