Submission #31235

#TimeUsernameProblemLanguageResultExecution timeMemory
31235gs14004Repeating Subsequence Tests (KRIII5_RST)C++14
7 / 7
976 ms424884 KiB
#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 (stderr)

RST.cpp: In function 'void init()':
RST.cpp:21:47: warning: array subscript has type 'char' [-Wchar-subscripts]
    sum[i][j] = (2ll * sum[i-1][j] - arr[str[i]][j] + mod) % mod;
                                               ^
RST.cpp:22:14: warning: array subscript has type 'char' [-Wchar-subscripts]
    arr[str[i]][j] = sum[i-1][j];
              ^
RST.cpp:31:26: warning: array subscript has type 'char' [-Wchar-subscripts]
    del[i][j] = arr[str[i]][j];
                          ^
RST.cpp:32:14: warning: array subscript has type 'char' [-Wchar-subscripts]
    arr[str[i]][j] = (2ll * arr[str[i]][j] - del[i-1][j] + mod) % mod;
              ^
RST.cpp:32:38: warning: array subscript has type 'char' [-Wchar-subscripts]
    arr[str[i]][j] = (2ll * arr[str[i]][j] - del[i-1][j] + mod) % mod;
                                      ^
RST.cpp: In function 'int main()':
RST.cpp:54:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s %d",str + 1,&q);
                           ^
RST.cpp:60:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d %d",&a[0],&b[0],&c0,&c1,&c2);
                                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...