QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201938#6395. Equation Discoveringucup-team870#WA 1ms4020kbC++142.3kb2023-10-05 17:44:352023-10-05 17:44:35

Judging History

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

  • [2023-10-05 17:44:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4020kb
  • [2023-10-05 17:44:35]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define ob pop_back
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
struct node{
    double x,y;
}a[25];
int n;
vector<int> q;
vector<double> st;
vector<string> an;
double eps=5e-4;
void pr(){
    for(auto o:q) cout<<o<<' '; cout<<endl;
    for(auto o:q){
        if (!o) an.pb("x");
        if (o==1){
            an[an.size()-1]="sin("+an[an.size()-1]+")";
        }
        if (o==2){
            an[an.size()-1]="cos("+an[an.size()-1]+")";
        }
        if (o>=3){
            string er=an.back(); an.ob();
            string qw=an.back();
            if (o==3) an[an.size()-1]="("+qw+"+"+er+")";
            if (o==4) an[an.size()-1]="("+qw+"-"+er+")";
            if (o==5) an[an.size()-1]="("+qw+"*"+er+")";
            if (o==6) an[an.size()-1]="("+qw+"/"+er+")";
        }
    }
    cout<<an[0]<<endl; exit(0);
}
void dfs(int siz,int cnt){
    if ((siz-1)*2>cnt) return;
    if (siz==1){
        For(i,1,n){
            double x=a[i].x,y=a[i].y; st.clear();
            for(auto o:q){
                if (!o) st.pb(x);
                if (o==1){
                    st[st.size()-1]=sin(st[st.size()-1]);
                }
                if (o==2){
                    st[st.size()-1]=cos(st[st.size()-1]);
                }
                if (o>=3){
                    double er=st.back(); st.ob();
                    double qw=st.back();
                    if (o==3) st[st.size()-1]=qw+er;
                    if (o==4) st[st.size()-1]=qw-er;
                    if (o==5) st[st.size()-1]=qw*er;
                    if (o==6){
                        if (er==0.0) goto E;
                        st[st.size()-1]=qw/er;
                    }
                }
            }
            double tt=fabs(st[0]-y)/max(1.0,fabs(y));
            if (tt>eps) goto E;
        }
        pr();
    }
    E:;
    //0
    q.pb(0); dfs(siz+1,cnt); q.ob();
    if (cnt>=1){
        q.pb(1); dfs(siz,cnt-1); q.ob();
        q.pb(2); dfs(siz,cnt-1); q.ob();
    }
    if (cnt>=2&&siz>=2){
        q.pb(3); dfs(siz-1,cnt-2); q.ob();
        q.pb(4); dfs(siz-1,cnt-2); q.ob();
        q.pb(5); dfs(siz-1,cnt-2); q.ob();
        q.pb(6); dfs(siz-1,cnt-2); q.ob();
    }
}
int main(){
    cin>>n;
    For(i,1,n) cin>>a[i].x>>a[i].y;
    q.pb(0); dfs(1,9);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4020kb

input:

3
1.000000 1.000000
2.000000 4.000000
3.000000 9.000000

output:

0 0 0 0 0 4 1 5 3 5 
(x*(x+(x*sin((x-x)))))

result:

wrong answer Token parameter [name=out-expr] equals to "0", doesn't correspond to pattern "[\+\-*/sincox\(\)]{1,1000}"