QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#746255 | #9568. Left Shifting 3 | ucup-team1769# | WA | 11ms | 3668kb | C++14 | 1.1kb | 2024-11-14 14:00:47 | 2024-11-14 14:00:47 |
Judging History
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
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'