QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#749988#9568. Left Shifting 3UESTC_DECAYALI#WA 0ms3544kbC++20669b2024-11-15 11:52:012024-11-15 11:52:01

Judging History

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

  • [2024-11-15 11:52:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3544kb
  • [2024-11-15 11:52:01]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>

int work() {
    int n, k;
    std::cin >> n >> k;
    k = std::min(n, k);
    std::string S; std::cin >> S;
    S += S.substr(0, k);
    int l = S.size();
    std::vector<int> s(l, 0);
    for(int i = 0; i <= l - 7; ++i) s[i] = (S.substr(i, 7) == "nanjing");
    for(int i = 1; i < l; ++i) s[i] += s[i - 1];
    int ans = s[n - 7];
    for(int i = 0, j = n - 6; j < l; ++i, ++j) ans = std::max(ans, s[j] - s[i]);
    return ans;
}

int main() {
    std::ios::sync_with_stdio(false);
    int T; std::cin >> T; while(T--) std::cout << work() << char(10);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3544kb

input:

4
21 10
jingicpcnanjingsuanan
21 0
jingicpcnanjingsuanan
21 3
nanjingnanjingnanjing
4 100
icpc

output:

2
1
3
49

result:

wrong answer 4th numbers differ - expected: '0', found: '49'