QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#750367 | #9568. Left Shifting 3 | QingTian# | WA | 13ms | 3712kb | C++20 | 1.0kb | 2024-11-15 14:20:26 | 2024-11-15 14:20:26 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define MAXN 300005
#define INf 2147483647
#define fn(i,st,ed) for(int i=st;i<=ed;i++)
#define fd(i,st,ed) for(int i=st;i>=ed;i--)
using namespace std;
inline int read(){
int x=0,f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-'0';c=getchar();}
return x*f;
}
void solve(){
int n,k,ans=0;cin>>n>>k;
string s;cin>>s;
s=s+s;
int cnt=0;
fn(i,0,2*n-7){
//cout<<s.substr(i,7)<<endl;
if(s.substr(i,7)=="nanjing")cnt++;
//cout<<cnt<<endl;
}
ans+=((n+k)/(n*2))*cnt;
//cout<<n<<' '<<k<<endl;
int now=(k+n)%(n*2);
//cout<<"now:"<<now<<endl;
fn(i,0,now-7){
//cout<<s.substr(i,7)<<endl;
if(s.substr(i,7)=="nanjing")ans++;
//cout<<ans<<endl;
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;cin>>T;
while(T--){solve();}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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: 13ms
memory: 3712kb
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 16337968 2 3 15588221 4 23764091 4 0 29208677 6602306 2094278 43872732 16487110 1 43125163 44501964 59003645 0 5453866 12700875 0 0 5306944 0 0 0 19792855 16689637 0 30860160 8765020 1 6482948 30117971 1 1 1 3 3 1 3 37746216 0 1 2 81975839 17386323 2 17973785 21472359 1 2 51720414 0 16905965 0...
result:
wrong answer 4th numbers differ - expected: '2', found: '16337968'