QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#744962 | #9568. Left Shifting 3 | PinkRabbit# | AC ✓ | 12ms | 8668kb | C++20 | 1.3kb | 2024-11-14 00:55:36 | 2024-11-14 00:55:36 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <string>
using std::cin, std::cout;
#define F(i, a, b) for(int i = a; i <= (b); ++i)
#define F2(i, a, b) for(int i = a; i < (b); ++i)
#define dF(i, a, b) for(int i = a; i >= (b); --i)
void Init();
void Solve();
int main() {
cin.sync_with_stdio(false);
cin.tie(nullptr);
Init();
int tests = 1;
cin >> tests;
while (tests--)
Solve();
return 0;
}
using LL = long long;
const int Mod = 998244353;
const int Inf = 0x3f3f3f3f;
const LL InfLL = 0x3f3f3f3f3f3f3f3f;
const int MN = 500005;
int n, m, q, k;
int a[MN], b[MN], f[MN], g[MN];
std::vector<int> G[MN];
void Init() {
}
void Solve() {
cin >> n >> k;
std::string s;
cin >> s;
if (n < 7)
return void(cout << "0\n");
F(i, 1, n)
a[i] = s[i - 1];
F(i, 1, n)
a[n + i] = a[i];
k = std::min(k, n - 1);
F(i, 1, 2 * n - 7 + 1) {
std::string s2(7, ' ');
F2(j, 0, 7)
s2[j] = a[i + j];
if (s2 == "nanjing")
b[i] = 1;
else
b[i] = 0;
}
F(i, 1, 2 * n - 7 + 1)
b[i] += b[i - 1];
int ans = 0;
F(i, 1, k + 1)
ans = std::max(ans, b[i + n - 7] - b[i - 1]);
cout << ans << '\n';
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 7916kb
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: 0
Accepted
time: 9ms
memory: 5716kb
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:
ok 2130 numbers
Test #3:
score: 0
Accepted
time: 12ms
memory: 8668kb
input:
3 100000 998244353 gbppzfsncqyzmuwrcvtxsciucxusskcjhaanwhqmyncytwhkubrvcqxgcehdxyewdyvpqjcmrnmlgrytrucexmmfulqbtfctehphmrzkosyvhtvjrromqncbgsjcwhmlqidkycaxyhsrduoxayntuhqubvboseeziwjvrfagsbvtxjjbexnajqapgxydwtztzbbdpoydnjipfizdfpmczgqvdmpvxbqubtygkfpdeonegfzsttirbhzkobbigwneyvtcxndfkljdvbbcfnadtfhgo...
output:
4 1649 3651
result:
ok 3 number(s): "4 1649 3651"
Extra Test:
score: 0
Extra Test Passed