QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740361 | #9568. Left Shifting 3 | sea_bird | WA | 17ms | 3704kb | C++20 | 1.1kb | 2024-11-13 09:22:09 | 2024-11-13 09:22:09 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
int f[(int)4e5 + 1000];
void solve(){
int n,k;
std::cin >> n >> k;
std::string s;
std::cin >> s;
s += s;
// std::fill(f + 1,f + 1 + (n << 1),0);
int n2 = s.size();
std::fill(f + 1,f + 1 + n2,0);
for(int i = 0;(i + 7) < n2;i++){
if(s.substr(i,7) == "nanjing"){
f[i + 1]++;
}
f[i + 1] += f[i];
}
int ans = 0;
// for(int i = 0;i <= n2;i ++){
// std::cout << f[i] << " ";
// }
// std::cout << "\n";
for(int i = 0;i < n and i <= k;i++){
int tmp = f[i + n] - f[i];
// j - l + 1 == 6
// l = i + n - 6
for(int j = i + n - 1;j >= i + n - 6 and j >= 0;j--){
if((j + 7) < n2 and s.substr(j,7) == "nanjing"){
tmp--;
}
}
ans = std::max(ans,tmp);
// ans = std::max(ans,f[i + n] - f[i]);
}
std::cout << ans << "\n";
}
int main(){
std::ios::sync_with_stdio(0);
std::cin.tie(0),std::cout.tie(0);
int t;
std::cin >> t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
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: 17ms
memory: 3704kb
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 0 4 2 0 3 3 0 0 0 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 0 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 0 0 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 18th numbers differ - expected: '1', found: '0'