QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#378523 | #8571. Palworld | ucup-team3396# | WA | 4ms | 8140kb | C++14 | 913b | 2024-04-06 13:22:40 | 2024-04-06 13:22:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
char ch[5000005];
int f[5000005];
signed main(){
ios::sync_with_stdio(0);cin.tie(0);
int t;cin>>t;
while(t--){
int n,k;cin>>n>>k;
ch[0]='#';ch[1]='$';
for(int i=1;i<=n;i++){
cin>>ch[2*i];
ch[2*i+1]='$';
}
ch[2*n+2]='%';
int mx=-1,y=-1;
for(int i=1;i<=2*n+1;i++){
f[i]=1;
if(mx>=i)f[i]=min(f[2*y-i],mx-i+1);
while(ch[i+f[i]]==ch[i-f[i]])f[i]++;
if(mx<i+f[i]-1)mx=i+f[i]-1,y=i;
}
int ans=min(n+k,2*k);
for(int i=1;i<=2*n+1;i++){
int l=i-f[i]+1;
int r=i+f[i]-1;
l=(l+1)/2;
r=(r-1)/2;
if(l>r)continue;
ans=max(ans,r-l+1+2*min(max(n-r,l-1),k));
}
cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5756kb
input:
4 1 3 a 4 1 icpc 4 2 icpc 8 4 icecream
output:
4 5 5 11
result:
ok 4 number(s): "4 5 5 11"
Test #2:
score: 0
Accepted
time: 4ms
memory: 7312kb
input:
1 200000 66 jsmwjmibgkjvdscqllsxpaxiycmpauhnzschbivtqbjfrxrqvhvfbqecozjewqqpwdfbeqppjkgxhbnniopkptkygspcdswhwadfwhnzovvpshgcdukrupeztkpxwhmctaquqbxtidzbbxsyuaeikuldaoeudletrsmqptaejibkymsjhmwykqsjdvvdaqwelrcpxwrwhuvodipjniowfofbjktkdezwqqbvwsppsmpilntmdmlxgkaxymnugmmcsljkjzjuudnllydwdwwanadynsoiolso...
output:
141
result:
ok 1 number(s): "141"
Test #3:
score: -100
Wrong Answer
time: 4ms
memory: 8140kb
input:
1 200000 100 qhiaajzxinenucrnfffumuhnovpuwcnojbhsktztapgyivmfqrlntwazwnfetwqieckxcnkskpidltiydfoveaucckximydxxfbiwbdufmbhywqkflyqxbijakadqkzftlciccbpnldsqhtjxuxnvkusvizavuyfhdroiuominebadhfqzrpjnzpgyvkejfwmueiltyeqpvwrkanqknyacqganbszktocfuvvsfrboaennwpaabfdnaurvvurysrijnfaonesihbhrrvbvyhpbremsuhhbc...
output:
207
result:
wrong answer 1st numbers differ - expected: '209', found: '207'