QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#715735 | #9568. Left Shifting 3 | Sulfox# | WA | 4ms | 3996kb | C++20 | 846b | 2024-11-06 13:13:48 | 2024-11-06 13:13:51 |
Judging History
answer
#include <bits/stdc++.h>
const int N = 2e5 + 5;
int n, k, a[N];
char str[N];
void run() {
scanf("%d%d", &n, &k);
scanf("%s", str);
if (n <= 6) { printf("0\n"); return; }
for (int i = 0; i < n; i++)
str[i + n] = str[i];
for (int i = 0; i < n + n; i++) {
a[i] = 0;
if (i + 6 < n + n && str[i] == 'n' && str[i + 1] == 'a' && str[i + 2] == 'n' && str[i + 3] == 'j' && str[i + 4] == 'i' && str[i + 5] == 'n' && str[i + 6] == 'g')
a[i] = 1;
}
a[n + n] = 0;
for (int i = n + n; i >= 1; i--)
a[i - 1] += a[i];
int ans = 0;
for (int i = 0; i <= std::min(k, n - 1); i++)
ans = std::max(ans, a[i] - a[i + (n - 5)]);
printf("%d\n", ans);
}
int main() {
int T;
scanf("%d", &T);
for (; T; T--) run();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
input:
4 21 10 jingicpcnanjingsuanan 21 0 jingicpcnanjingsuanan 21 3 nanjingnanjingnanjing 4 100 icpc
output:
2 1 3 0
result:
ok 4 number(s): "2 1 3 0"
Test #2:
score: -100
Wrong Answer
time: 4ms
memory: 3996kb
input:
2130 39 7 nnananjingannanjingngnanjinganjinggjina 1 479084228 g 33 2 gqnanjinggrjdtktnanjingcvsenanjin 24 196055605 ginganjingnanjingnanjing 23 3 ngnanjinganjingjinnanji 40 3 njingaaznannanjingnananjingyonwpnanjinga 40 207842908 nanjinggphconanjingkonanjinannanjinglxna 46 3 ingjingnnanjingnanjinging...
output:
3 0 3 2 2 3 3 4 3 4 0 2 4 3 2 1 1 1 4 2 0 3 3 1 0 1 0 0 0 5 4 0 1 2 1 2 2 1 1 1 3 3 1 4 2 0 1 2 4 1 2 1 2 1 2 3 0 1 0 0 1 1 3 3 2 1 0 3 1 2 1 1 4 4 1 1 1 1 0 1 1 1 1 2 0 4 4 3 1 1 2 1 1 1 1 5 1 4 0 1 2 1 3 4 3 3 3 3 1 3 2 1 3 1 2 0 0 2 0 5 0 2 0 3 1 0 2 2 3 2 1 2 0 1 1 1 2 4 1 4 2 0 1 1 2 2 2 1 0 3 ...
result:
wrong answer 24th numbers differ - expected: '0', found: '1'