QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#805275 | #9568. Left Shifting 3 | victoryAC# | WA | 8ms | 3748kb | C++23 | 1.6kb | 2024-12-08 15:17:25 | 2024-12-08 15:17:25 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
#define endl '\n'
const int N=1e6+10;
const int mod=1e9+7;
const double eps=1e-9;
ll a[1010][1010];
vector<PII> v;
bool check1(int mid, ll l){
if(v[mid].first >= l)return true;
else return false;
}
bool check2(int mid, ll r){
if(v[mid].second <= r)return true;
else return false;
}
void solve()
{
v.clear();
ll n,k;
cin>>n>>k;
string s;
cin>>s;
s+=s.substr(0,min(n,k));
s=' '+s;
ll m=s.size()-1;
int ans=0;
for(int i=1;i+6<=m;i++)
{
string t=s.substr(i,7);
if(t=="nanjing")
{
ans++;
i+=6;
v.push_back({i, i + 6});
}
}
if(v.size() == 0){
cout << 0 << endl;
return;
}
for(int i = 1; i + n - 1 <= m; i ++ ){
int nl = i, nr = i + n - 1;
int l = 0, r = v.size() - 1;
while(l < r){
int mid = l + r >> 1;
if(check1(mid, nl)) r = mid;
else l = mid + 1;
}
if(check1(l, nl) == false)continue;
int c1 = l;
l = 0, r = v.size() - 1;
while(l < r){
int mid = l + r + 1 >> 1;
if(check2(mid, nr)) l = mid;
else r = mid - 1;
}
int c2 = l;
ans = max(ans, max(0, c2 - c1 + 1));
}
cout << ans << endl;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _=1;
cin>>_;
while(_--)
{
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: 8ms
memory: 3748kb
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 4 2 3 6 4 6 4 0 4 8 5 4 2 1 1 7 3 0 5 5 0 0 1 0 0 0 10 8 0 1 4 1 3 3 1 1 1 3 3 1 3 3 0 1 2 8 1 2 1 3 1 2 5 0 1 0 0 2 1 3 2 3 1 0 3 1 3 1 1 4 7 1 1 1 1 0 1 2 2 1 3 0 8 8 6 1 1 2 1 2 1 1 9 2 7 0 2 4 1 3 7 3 5 6 6 1 3 4 2 6 1 3 0 0 1 0 9 0 4 0 6 2 0 2 4 3 4 2 3 0 1 1 1 3 4 1 3 3 0 1 1 2 4 2 1 0 6...
result:
wrong answer 4th numbers differ - expected: '2', found: '4'