QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#378523#8571. Palworlducup-team3396#WA 4ms8140kbC++14913b2024-04-06 13:22:402024-04-06 13:22:41

Judging History

你现在查看的是最新测评结果

  • [2024-04-06 13:22:41]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:8140kb
  • [2024-04-06 13:22:40]
  • 提交

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;
}

详细

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'