QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770864#9568. Left Shifting 3RUOHUIWA 3ms3860kbC++201.2kb2024-11-22 00:58:142024-11-22 00:58:15

Judging History

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

  • [2024-11-22 00:58:15]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3860kb
  • [2024-11-22 00:58:14]
  • 提交

answer

#include "bits/stdc++.h"
#define int long long
#define ull unsigned long long
#define PII pair<int, int>
#define TIII tuple<int, int, int>
#define LL __int128
#define eps 1e-6
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
constexpr int N = 2e6 + 10, M = 2e6 + 10, mod = 1e9 + 7, inf = 1e18;
int n, m;

void solve()
{
    int k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ans = 0;
    if (k > 7)
    {
        s += s;
        for (int i = 0; i < s.size() / 2; i++)
        {
            if (s.substr(i, 7) == "nanjing")
                ans++;
        }
        cout << ans << endl;
    }
    else
    {
        s += s.substr(0, k);
        for (int i = 0; i < s.size(); i++)
        {
            if (s.substr(i, 7) == "nanjing")
                ans++;
        }
        cout << ans << endl;
    }
}

signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(2);

#ifndef ONLINE_JUDGE
    freopen("in.txt", "rt", stdin);
    freopen("out.txt", "wt", stdout);
#endif

    int Cases = 1;
    cin >> Cases;
    while (Cases--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3ms
memory: 3700kb

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
0
0
1
0
0
0
5
4
0
1
2
1
2
2
1
1
1
3
3
1
3
2
0
1
2
4
1
2
1
2
1
2
3
0
1
0
0
1
1
3
2
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
1
0
5
0
2
0
3
1
0
2
2
3
2
1
2
0
1
1
1
2
4
1
3
2
0
1
1
2
2
2
1
0
3
...

result:

wrong answer 269th numbers differ - expected: '1', found: '2'