# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31235 | 2017-08-14T16:36:28 Z | gs14004 | Repeating Subsequence Tests (KRIII5_RST) | C++14 | 976 ms | 424884 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pi; typedef long long lint; const int MAXN = 1000005; const int E = 52; const int mod = 1e9 + 7; int n, q; char str[MAXN]; int sum[MAXN][E+1]; int del[MAXN][E+1]; int arr[E+1][E+1]; void init(){ for(int i=0; i<=E; i++){ arr[i][i] = sum[0][i] = 1; } for(int i=1; i<=n; i++){ for(int j=0; j<=E; j++){ sum[i][j] = (2ll * sum[i-1][j] - arr[str[i]][j] + mod) % mod; arr[str[i]][j] = sum[i-1][j]; } } memset(arr, 0, sizeof(arr)); for(int i=0; i<=E; i++){ arr[i][i] = 1; } for(int i=1; i<=n; i++){ for(int j=0; j<=E; j++){ del[i][j] = arr[str[i]][j]; arr[str[i]][j] = (2ll * arr[str[i]][j] - del[i-1][j] + mod) % mod; } } } int query(int s, int e){ lint ret = 0; for(int i=0; i<=E; i++){ ret += 1ll * sum[e][i] * (mod + (i == E) - del[s-1][i]) % mod; } ret %= mod; return ret; } int a[MAXN], b[MAXN]; int code(char x){ if(x >= 'A' && x <= 'Z') return x - 'A'; return x - 'a' + 26; } int main(){ scanf("%s %d",str + 1,&q); n = strlen(str + 1); for(int i=1; i<=n; i++){ str[i] = code(str[i]); } int c0, c1, c2; scanf("%d %d %d %d %d",&a[0],&b[0],&c0,&c1,&c2); for(int i=1; i<=q; i++){ a[i] = (1ll * a[i-1] * c0 + 1ll * b[i-1] * c1 + c2) % mod; b[i] = (1ll * b[i-1] * c0 + 1ll * a[i-1] * c1 + c2) % mod; } init(); int ans = 0; for(int i=1; i<=q; i++){ a[i] %= n; b[i] %= n; if(a[i] > b[i]) swap(a[i], b[i]); a[i]++; b[i]++; ans ^= query(a[i], b[i]); } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 424884 KB | Output is correct |
2 | Correct | 16 ms | 424884 KB | Output is correct |
3 | Correct | 16 ms | 424884 KB | Output is correct |
4 | Correct | 19 ms | 424884 KB | Output is correct |
5 | Correct | 19 ms | 424884 KB | Output is correct |
6 | Correct | 76 ms | 424884 KB | Output is correct |
7 | Correct | 76 ms | 424884 KB | Output is correct |
8 | Correct | 33 ms | 424884 KB | Output is correct |
9 | Correct | 39 ms | 424884 KB | Output is correct |
10 | Correct | 9 ms | 424884 KB | Output is correct |
11 | Correct | 6 ms | 424884 KB | Output is correct |
12 | Correct | 0 ms | 424884 KB | Output is correct |
13 | Correct | 0 ms | 424884 KB | Output is correct |
14 | Correct | 3 ms | 424884 KB | Output is correct |
15 | Correct | 6 ms | 424884 KB | Output is correct |
16 | Correct | 3 ms | 424884 KB | Output is correct |
17 | Correct | 6 ms | 424884 KB | Output is correct |
18 | Correct | 3 ms | 424884 KB | Output is correct |
19 | Correct | 6 ms | 424884 KB | Output is correct |
20 | Correct | 13 ms | 424884 KB | Output is correct |
21 | Correct | 9 ms | 424884 KB | Output is correct |
22 | Correct | 13 ms | 424884 KB | Output is correct |
23 | Correct | 9 ms | 424884 KB | Output is correct |
24 | Correct | 6 ms | 424884 KB | Output is correct |
25 | Correct | 86 ms | 424884 KB | Output is correct |
26 | Correct | 83 ms | 424884 KB | Output is correct |
27 | Correct | 79 ms | 424884 KB | Output is correct |
28 | Correct | 83 ms | 424884 KB | Output is correct |
29 | Correct | 76 ms | 424884 KB | Output is correct |
30 | Correct | 83 ms | 424884 KB | Output is correct |
31 | Correct | 66 ms | 424884 KB | Output is correct |
32 | Correct | 69 ms | 424884 KB | Output is correct |
33 | Correct | 89 ms | 424884 KB | Output is correct |
34 | Correct | 66 ms | 424884 KB | Output is correct |
35 | Correct | 79 ms | 424884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 424884 KB | Output is correct |
2 | Correct | 16 ms | 424884 KB | Output is correct |
3 | Correct | 16 ms | 424884 KB | Output is correct |
4 | Correct | 19 ms | 424884 KB | Output is correct |
5 | Correct | 19 ms | 424884 KB | Output is correct |
6 | Correct | 76 ms | 424884 KB | Output is correct |
7 | Correct | 76 ms | 424884 KB | Output is correct |
8 | Correct | 33 ms | 424884 KB | Output is correct |
9 | Correct | 39 ms | 424884 KB | Output is correct |
10 | Correct | 9 ms | 424884 KB | Output is correct |
11 | Correct | 6 ms | 424884 KB | Output is correct |
12 | Correct | 0 ms | 424884 KB | Output is correct |
13 | Correct | 0 ms | 424884 KB | Output is correct |
14 | Correct | 3 ms | 424884 KB | Output is correct |
15 | Correct | 6 ms | 424884 KB | Output is correct |
16 | Correct | 3 ms | 424884 KB | Output is correct |
17 | Correct | 6 ms | 424884 KB | Output is correct |
18 | Correct | 3 ms | 424884 KB | Output is correct |
19 | Correct | 6 ms | 424884 KB | Output is correct |
20 | Correct | 13 ms | 424884 KB | Output is correct |
21 | Correct | 9 ms | 424884 KB | Output is correct |
22 | Correct | 13 ms | 424884 KB | Output is correct |
23 | Correct | 9 ms | 424884 KB | Output is correct |
24 | Correct | 6 ms | 424884 KB | Output is correct |
25 | Correct | 86 ms | 424884 KB | Output is correct |
26 | Correct | 83 ms | 424884 KB | Output is correct |
27 | Correct | 79 ms | 424884 KB | Output is correct |
28 | Correct | 83 ms | 424884 KB | Output is correct |
29 | Correct | 76 ms | 424884 KB | Output is correct |
30 | Correct | 83 ms | 424884 KB | Output is correct |
31 | Correct | 66 ms | 424884 KB | Output is correct |
32 | Correct | 69 ms | 424884 KB | Output is correct |
33 | Correct | 89 ms | 424884 KB | Output is correct |
34 | Correct | 66 ms | 424884 KB | Output is correct |
35 | Correct | 79 ms | 424884 KB | Output is correct |
36 | Correct | 169 ms | 424884 KB | Output is correct |
37 | Correct | 166 ms | 424884 KB | Output is correct |
38 | Correct | 179 ms | 424884 KB | Output is correct |
39 | Correct | 206 ms | 424884 KB | Output is correct |
40 | Correct | 203 ms | 424884 KB | Output is correct |
41 | Correct | 486 ms | 424884 KB | Output is correct |
42 | Correct | 949 ms | 424884 KB | Output is correct |
43 | Correct | 949 ms | 424884 KB | Output is correct |
44 | Correct | 856 ms | 424884 KB | Output is correct |
45 | Correct | 869 ms | 424884 KB | Output is correct |
46 | Correct | 849 ms | 424884 KB | Output is correct |
47 | Correct | 846 ms | 424884 KB | Output is correct |
48 | Correct | 839 ms | 424884 KB | Output is correct |
49 | Correct | 806 ms | 424884 KB | Output is correct |
50 | Correct | 873 ms | 424884 KB | Output is correct |
51 | Correct | 946 ms | 424884 KB | Output is correct |
52 | Correct | 909 ms | 424884 KB | Output is correct |
53 | Correct | 976 ms | 424884 KB | Output is correct |
54 | Correct | 939 ms | 424884 KB | Output is correct |
55 | Correct | 976 ms | 424884 KB | Output is correct |
56 | Correct | 853 ms | 424884 KB | Output is correct |
57 | Correct | 839 ms | 424884 KB | Output is correct |
58 | Correct | 843 ms | 424884 KB | Output is correct |
59 | Correct | 973 ms | 424884 KB | Output is correct |
60 | Correct | 876 ms | 424884 KB | Output is correct |
61 | Correct | 896 ms | 424884 KB | Output is correct |
62 | Correct | 856 ms | 424884 KB | Output is correct |
63 | Correct | 879 ms | 424884 KB | Output is correct |
64 | Correct | 619 ms | 424884 KB | Output is correct |
65 | Correct | 493 ms | 424884 KB | Output is correct |
66 | Correct | 556 ms | 424884 KB | Output is correct |
67 | Correct | 533 ms | 424884 KB | Output is correct |
68 | Correct | 499 ms | 424884 KB | Output is correct |
69 | Correct | 536 ms | 424884 KB | Output is correct |
70 | Correct | 549 ms | 424884 KB | Output is correct |
71 | Correct | 919 ms | 424884 KB | Output is correct |
72 | Correct | 966 ms | 424884 KB | Output is correct |
73 | Correct | 923 ms | 424884 KB | Output is correct |
74 | Correct | 956 ms | 424884 KB | Output is correct |
75 | Correct | 973 ms | 424884 KB | Output is correct |
76 | Correct | 896 ms | 424884 KB | Output is correct |
77 | Correct | 896 ms | 424884 KB | Output is correct |
78 | Correct | 969 ms | 424884 KB | Output is correct |
79 | Correct | 943 ms | 424884 KB | Output is correct |
80 | Correct | 916 ms | 424884 KB | Output is correct |