QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#734258 | #9568. Left Shifting 3 | orz_z | WA | 0ms | 3796kb | C++14 | 4.1kb | 2024-11-11 08:09:09 | 2024-11-11 08:09:09 |
Judging History
answer
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC optimize("Ofast,fast-math")
//#pragma GCC target("avx,avx2")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;
#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)
template<typename T> void debug(string s, T x) {
cerr << "[" << s << "] = [" << x << "]\n";
}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {
for (int i = 0, b = 0; i < (int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++;
else if (s[i] == ')' || s[i] == '}') b--;
else if (s[i] == ',' && b == 0) {
cerr << "[" << s.substr(0, i) << "] = [" << x << "] | ";
debug(s.substr(s.find_first_not_of(' ', i + 1)), args...);
break;
}
}
#ifdef ONLINE_JUDGE
#define Debug(...)
#else
#define Debug(...) debug(#__VA_ARGS__, __VA_ARGS__)
#endif
#define pb push_back
#define fi first
#define se second
#define Mry fprintf(stderr, "%.3lf MB\n", (&Med - &Mbe) / 1048576.0)
#define Try cerr << 1e3 * clock() / CLOCKS_PER_SEC << " ms\n";
typedef long long ll;
// namespace Fread {const int SIZE = 1 << 17; char buf[SIZE], *S, *T; inline char getchar() {if (S == T) {T = (S = buf) + fread(buf, 1, SIZE, stdin); if (S == T) return '\n';} return *S++;}}
// namespace Fwrite {const int SIZE = 1 << 17; char buf[SIZE], *S = buf, *T = buf + SIZE; inline void flush() {fwrite(buf, 1, S - buf, stdout), S = buf;} inline void putchar(char c) {*S++ = c;if (S == T) flush();} struct NTR {~NTR() {flush();}} ztr;}
// #ifdef ONLINE_JUDGE
// #define getchar Fread::getchar
// #define putchar Fwrite::putchar
// #endif
inline int ri() {
int x = 0;
bool t = 0;
char c = getchar();
while (c < '0' || c > '9') t |= c == '-', c = getchar();
while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
return t ? -x : x;
}
inline void wi(int x) {
if (x < 0) {
putchar('-'), x = -x;
}
if (x > 9) wi(x / 10);
putchar(x % 10 + 48);
}
inline void wi(int x, char s) {
wi(x), putchar(s);
}
bool Mbe;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3f;
const int _ = 2e5 + 5;
string s = "nanjing";
int n, k;
char str[_], str2[_];
bool flg[_];
void solve() {
n = ri(), k = ri();
scanf("%s", str + 1);
F(i, 1, n) flg[i] = 0;
int ans = 0;
F(z, 0, min(k, 7)) {
int tk = 0, res = 0;
F(j, z + 1, n) {
str2[++tk] = str[j];
}
F(j, 1, z) {
str2[++tk] = str[j];
}
F(j, 1, n) {
if(j + 6 <= n && str[j] == 'n' && str[j + 1] == 'a' && str[j + 2] == 'n' && str[j + 3] == 'j' && str[j + 4] == 'i' && str[j + 5] == 'n' && str[j + 6] == 'g') {
res++;
j += 6;
}
}
ans = max(ans, res);
}
cout << ans << '\n';
// int nw = 0;
// int ans = 0;
// vi A;
// F(i, 1, n) {
// if(str[i] == s[nw]) {
// if(!nw) {
// nw++;
// A.pb(i);
// } else if(i == A.back() + 1) {
// A.pb(i);
// nw++;
// }
// } else if(nw > 0 && str[i] == s[nw - 1]) {
// A.pop_back();
// A.pb(i);
// }
// if(nw == 7) {
// nw = 0;
// for(int v : A) flg[v] = 1;
// ans++;
// }
// }
// int fi = 0;
// F(i, 1, n) if(flg[i]) {
// fi = i - 1;
// break;
// }
// fi = min(fi, k);
// F(i, 1, fi) {
// if(str[i] == s[nw]) {
// if(!nw) {
// nw++;
// A.pb(i);
// } else if(i == A.back() % n + 1) {
// A.pb(i);
// nw++;
// }
// } else if(nw > 0 && str[i] == s[nw - 1]) {
// A.pop_back();
// A.pb(i);
// }
// if(nw == 7) {
// nw = 0;
// for(int v : A) flg[v] = 1;
// ans++;
// }
// }
// cout <<ans << '\n';
}
bool Med;
signed main() {
// Mry;
int T = ri();
while(T--) solve();
// Try;
return 0;
}
/*
24 196055605
ginganjingnanjingnanjing
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3796kb
input:
4 21 10 jingicpcnanjingsuanan 21 0 jingicpcnanjingsuanan 21 3 nanjingnanjingnanjing 4 100 icpc
output:
1 1 3 0
result:
wrong answer 1st numbers differ - expected: '2', found: '1'