QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#56584 | #4375. String | qinjianbin | Compile Error | / | / | C++ | 1.4kb | 2022-10-20 12:03:39 | 2022-10-20 12:03:39 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-10-20 12:03:39]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-10-20 12:03:39]
- 提交
answer
#include<iostream>
#define ll long long
using namespace std;
const int MAXN = 1e6 + 10;
const int MOD = 998244353;
char str[MAXN];
int z[MAXN], len;
void GetZ(char str[], int n, int z[]) {
int l = 0, r = 0;
z[0] = n;
for (int i = 1; i < n; i++) {
z[i] = i > r ? 0 : min(r - i + 1, z[i - l]);
while (z[i] + i < n && str[z[i]] == str[i + z[i]]) z[i]++;
if (i + z[i] - 1 > r) {
l = i;
r = i + z[i] - 1;
}
}
}
int T;
int k;
int a[MAXN];
int main() {
#ifdef TanJI
freopen("D:\\Cpp\\1.in", "r", stdin);
freopen("D:\\Cpp\\1.out", "w", stdout);
#endif
scanf("%d", &T);
while (T--) {
scanf("%s", str);
scanf("%d", &k);
len = strlen(str);
GetZ(str, len, z);
for (int i = 0; i < len; i++) a[i] = 0;
for (int i = 0; i < len; i++) {
//z[i]是长度,z[i] - 1是下标,
if (z[i] > i) {
int l = (z[i] - i) / k - 1, r = -1;
int offset = i + z[i] - 1 - ((z[i] - i) % k);
a[offset - l * k]++;
a[offset - r * k]--;
}
}
for (int i = k; i < len; i++) {
a[i] += a[i - k];
}
ll ans = 1;
for (int i = 0; i < len; i++)
ans = ans * (a[i] + 1) % MOD;
printf("%lld\n", ans);
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:34:15: error: ‘strlen’ was not declared in this scope 34 | len = strlen(str); | ^~~~~~ answer.code:2:1: note: ‘strlen’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 1 | #include<iostream> +++ |+#include <cstring> 2 | #define ll long long answer.code:30:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 30 | scanf("%d", &T); | ~~~~~^~~~~~~~~~ answer.code:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%s", str); | ~~~~~^~~~~~~~~~~ answer.code:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d", &k); | ~~~~~^~~~~~~~~~