QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203567#2476. Pizzo CollectorsVengeful_SpiritCompile Error//C++141.7kb2023-10-06 18:14:582023-10-06 18:14:58

Judging History

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

  • [2023-10-06 18:14:58]
  • 评测
  • [2023-10-06 18:14:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int p;
const int N=100005;
const int INF=1e17;
int f[N][19][27];
int val[26];
char s[N],t[N];
long long 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],f[i][j][26]=max(f[i][j][26],f[i][j][c]);
        }
        else{
            for(int c=0;c<26;c++)f[i][j][c]=-INF;
            f[i][j][26]=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;}
                if(f[i][j][c]!=-INF)f[i][j][c]+=f[i+k*bs[j]][j+1][c];
            }
            if(f[i][j][c]!=-INF)f[i][j][c]+=len*val[c];
            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;
    }
    if(n==1){
        int ans=0;
        if(s[1]=='?'){
            for(int i=0;i<26;i++)ans=max(ans,val[i]);
        }    
        else ans=val[s[1]-'A'];
        cout<<ans<<endl;
        return 0;
    }
    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;
        if(bs[i]==n)break;
    }
    dfs(1,n,0);
    printf("%lld\n",f[1][0][26]);
}

Details

answer.code:9:15: error: expected initializer before ‘;’
    9 | char s[N],t[N];
      |               ^~
answer.code: In function ‘void dfs(long long int, long long int, long long int)’:
answer.code:24:22: error: ‘bs’ was not declared in this scope; did you mean ‘s’?
   24 |             dfs(i+k*(bs[j]),len/p,j+1);
      |                      ^~
      |                      s
answer.code:27:32: error: ‘bs’ was not declared in this scope; did you mean ‘s’?
   27 |             f[i][j][26]+=f[i+k*bs[j]][j+1][26];
      |                                ^~
      |                                s
answer.code:31:26: error: ‘bs’ was not declared in this scope; did you mean ‘s’?
   31 |                 if(f[i+k*bs[j]][j+1][c]<=-INF){f[i][j][c]=-INF;break;}
      |                          ^~
      |                          s
answer.code:32:55: error: ‘bs’ was not declared in this scope; did you mean ‘s’?
   32 |                 if(f[i][j][c]!=-INF)f[i][j][c]+=f[i+k*bs[j]][j+1][c];
      |                                                       ^~
      |                                                       s
answer.code: In function ‘int main()’:
answer.code:46:24: error: ‘t’ was not declared in this scope
   46 |         scanf("%s%lld",t,&x);
      |                        ^
answer.code:65:5: error: ‘bs’ was not declared in this scope; did you mean ‘s’?
   65 |     bs[0]=1;
      |     ^~
      |     s
answer.code:41:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   41 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
answer.code:42:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   42 |     scanf("%s",s+1);
      |     ~~~~~^~~~~~~~~~
answer.code:43:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   43 |     scanf("%lld",&m);
      |     ~~~~~^~~~~~~~~~~