QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#297497#7858. Basic Equation Solvingucup-team1525#Compile Error//C++202.8kb2024-01-04 16:31:532024-01-04 16:31:53

Judging History

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

  • [2024-03-20 11:12:17]
  • hack成功,自动添加数据
  • (/hack/581)
  • [2024-01-04 16:31:53]
  • 评测
  • [2024-01-04 16:31:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=50;
const int mod=998244353;
int add(int x,int y){ return (x+=y)>=mod?x-mod:x; }
int sub(int x,int y){ return (x-=y)<0?x+mod:x; }
int n;
char s[N+5];
int tp[N+5];
char a[N+5][N+5],b[N+5][N+5];
int f[N+5];
int g[N+5];
int id(char c){
    return c>='0'||c<='9'?c-'0':c-'A'+10;
}
int find(int x){ return f[x]==x?x:f[x]=find(f[x]); }
void merge(int u,int v){
    u=find(u); v=find(v);
    if(u==v) return;
    if(u<v) swap(u,v);
    f[u]=v;
}
int ll[N+5];
int gre[N+5],les[N+5];
int tf[N+5];
int e[N+5][N+5];
int fe[N+5][N+5];
int ff(int x){ return tf[x]==x?x:tf[x]=find(tf[x]); }
void mer(int u,int v){
    u=ff(u); v=ff(v);
    if(u==v) return;
    if(u<v) swap(u,v);
    tf[u]=v;
}
void calc(){
    int m=36;
    for(int i=1;i<=m;i++) tf[i]=f[i];
    for(int i=1;i<=n;i++){
        if(!tp[i]) continue;
        for(int j=0;j<ll[i];j++)
            merge(id(a[i][j]),id(b[i][j]));
    }
    for(int i=0;i<10;i++)
        if(ff(i)!=i) return;
    memset(e,0,sizeof e);
    memset(fe,0,sizeof fe);
    memset(les,0x3f,sizeof les);
    memset(gre,-1,sizeof gre);
    for(int i=0;i<10;i++){
        if(!tp[i]) continue;
        int j=ll[i];
        int u=id(a[i][j]),v=id(b[i][j]);
        u=ff(u); v=ff(v);
        if(u==v) return;
        if(u<10&&v<10){
            if(u<=v) return;
        }
        else if(u<10)
            les[v]=min(les[v],u);
        else if(v<10)
            gre[u]=max(gre[u],v);
        else{
            e[u][v]=1; fe[u][v]=fe[v][u]=1;
        }
    }
    int tmp=1;
    for(int i=1;i<=n;i++)
        
}
void dfs(int i){
    if(i==n+1) calc();
    int m=strlen(a[i]);
    if(!tp[i]){
        dfs(i+1); return;
    }
    for(int j=0;j<m;j++){
        ll[i]=j; dfs(i+1);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<=36;i++) f[i]=i;
    for (int i=1;i<=n;++i)
    {
        scanf("%s",s);
        int len=strlen(s);
        for (int i=0;i<len;++i)
            if (s[i]=='='||s[i]=='<'||s[i]=='>')
            {
                int la=i,lb=len-i-1;
                int mx=max(la,lb);
                for(int j=0;j<mx-la;j++)
                    a[i][j]='0';
                for(int j=mx-la;j<mx;j++)
                    a[i][j]=s[j-mx+la];
                for(int j=0;j<mx-lb;j++)
                    b[i][j]='0';
                for(int j=mx-lb;j<lb;j++)
                    b[i][j]=s[i+1+j-mx+lb];
                if(s[i]=='='){
                    for(int j=0;j<mx;j++)
                        merge(id(a[i][j]),id(b[i][j]));
                }
                else if(s[i]=='<'){
                    tp[i]=1;
                    swap(a[i],b[i]);
                }
            }
    }
    dfs(1);
    printf("%d\n",ans);
    return 0;
}

Details

answer.code: In function ‘void calc()’:
answer.code:69:1: error: expected primary-expression before ‘}’ token
   69 | }
      | ^
answer.code: In function ‘int main()’:
answer.code:112:19: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
  112 |     printf("%d\n",ans);
      |                   ^~~
      |                   abs
answer.code:82:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   82 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
answer.code:86:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   86 |         scanf("%s",s);
      |         ~~~~~^~~~~~~~