QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#746255#9568. Left Shifting 3ucup-team1769#WA 11ms3668kbC++141.1kb2024-11-14 14:00:472024-11-14 14:00:47

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 14:00:47]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3668kb
  • [2024-11-14 14:00:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
void sol()
{
    int N, K;
    cin >> N >> K;
    string str;
    cin >> str;
    vector<int> is_hok(N, 0);
    vector<int> pre(N, 0);
    string str_cmp = "nanjing";
    if (str.size() < 7)
    {
        cout << "0\n";
        return;
    }
    for (int i = 0; i < N; i++)
    {
        bool is_ok = true;
        for (int j = 0; j < 7; j++)
        {
            if (str[(i + j) % N] != str_cmp[j])
            {
                is_ok = false;
                break;
            }
        }
        if (is_ok)
        {
            is_hok[i] = 1;
        }
    }
    for (int i = 0; i < N; i++)
    {
        pre[i] = (i != 0 ? pre[i - 1] : 0) + is_hok[i];
    }
    int ans = 0;
    for (int i = 0; i <= min(K, N - 1); i++)
    {
        if (i >= 7)
            ans = max(ans, pre[N - 1] - (pre[i] - pre[max(i - 6, 0)]));
        else
            ans = max(ans, pre[N - 1] - (pre[i] - pre[0] + pre[N - 1] - pre[N - 1 - (6 - i) + 1]));
    }
    cout << ans << "\n";
}
int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        sol();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3588kb

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: 11ms
memory: 3668kb

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
50368
3
4
209
1
1
4
3
0
3
80
1
0
1
0
0
0
5
161
0
97
2
64
2
2
1
1
1
3
3
1
4
113
0
1
2
4
49
2
1
3
1
2
113
0
1
0
0
1
1
3
3
3
209
0
3
1
2
1
1
4
161
1
97
1
1
0
1
1
193
1
2
0
4
4
3
1
1
2
1
1
1
1
5
1
4
0
1
49665
1
3
4
3
3
3
3
1
3
161
3
3
1
2
0
0
2
0
5
0
2
0
3
1
0
2
3
3
2
1
3
0
1
97
...

result:

wrong answer 13th numbers differ - expected: '4', found: '50368'