QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#203428#2476. Pizzo CollectorsVengeful_Spirit#WA 0ms3976kbC++141.6kb2023-10-06 17:24:202023-10-06 17:24:20

Judging History

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

  • [2023-10-06 17:24:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3976kb
  • [2023-10-06 17:24:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int p;
const int N=100001;
const int INF=1e9;
int f[N][18][27];
int val[26];
char s[N],t[N],bs[N];
int n,m;
void dfs(int i,int len,int j){
    if(len==1){
        if(s[i]=='?'){
            for(int c=0;c<26;c++)f[i][j][c]=val[c];
        }
        else{
            for(int c=0;c<26;c++)f[i][j][c]=-INF;
            f[i][j][s[i]-'A']=val[s[i]-'A'];
        }
    }
    else{
        for(int k=0;k<p;k++){
            dfs(i+k*(bs[j]),len/p,j+1);
        }
        for(int k=0;k<p;k++){
            f[i][j][26]+=f[i+k*bs[j]][j+1][26];
        }
        for(int c=0;c<26;c++){
            for(int k=0;k<p;k++){
                if(f[i+k*bs[j]][j+1][c]<=-INF){f[i][j][c]=-INF;break;}
                f[i][j][c]+=f[i+k*bs[j]][j+1][c];
      //          cout<<"c: "<<c<<" "<<i+k*(len/p)<<" "<<j+1<<" "<<f[i][j][c]<<endl;
            }
         //   cout<<"c: "<<c<<" "<<f[i][j][c]<<endl;
            f[i][j][c]+=len*val[c];
         //   cout<<"c: "<<c<<" "<<f[i][j][c]<<endl;
            f[i][j][26]=max(f[i][j][26],f[i][j][c]);
        }
        
    }
}
signed main(){
    scanf("%lld",&n);
    scanf("%s",s+1);
    scanf("%lld",&m);
    for(int i=1;i<=m;i++){
        int x;
        scanf("%s%lld",t,&x);
        val[t[0]-'A']=x;
    }
    for(int i=2;i<=n;i++){
        if(n%i==0){
            p=n;
            while(p!=1)p/=i;
            p=i;break;
        }
    }
    bs[0]=1;
    for(int i=1;i<=20;i++){
        bs[i]=bs[i-1]*p;
    }
    dfs(1,n,0);
    printf("%lld\n",f[1][0][26]);
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3976kb

input:

8
?A?B?A?C
3
A 1
B 1000
C 100000

output:

1200004

result:

wrong answer 1st lines differ - expected: '1301004', found: '1200004'