QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#559984#6395. Equation DiscoveringchimeraWA 29ms42720kbC++173.8kb2024-09-12 11:08:322024-09-12 11:08:33

Judging History

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

  • [2024-09-12 11:08:33]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:42720kb
  • [2024-09-12 11:08:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll int
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")


vector<vector<ll>> ids(10);
vector<vector<ll>> history(1);

void pprint(ll id) {
    if(history[id][0] == -1) cout << "x";
    else if(history[id][0] == 0) {
        cout << "sin("; pprint(history[id][1]); cout << ")";
    } else if(history[id][0] == 1) {
        cout << "cos("; pprint(history[id][1]); cout << ")";
    } else if(history[id][0] == 2) {
        cout << "("; pprint(history[id][1]); cout << "+"; pprint(history[id][2]); cout << ")";
    } else if(history[id][0] == 3) {
        cout << "("; pprint(history[id][1]); cout << "*"; pprint(history[id][2]); cout << ")";
    } else if(history[id][0] == 4) {
        cout << "("; pprint(history[id][1]); cout << "-"; pprint(history[id][2]); cout << ")";
    } else if(history[id][0] == 5) {
        cout << "("; pprint(history[id][1]); cout << "/"; pprint(history[id][2]); cout << ")";
    }
}

int main() {
    ll N; cin >> N;
    vector<array<double, 2>> ps(N);
    for(ll i = 0; i < N; i++) cin >> ps[i][0] >> ps[i][1];

    vector<vector<vector<double>>> exprs(10);

    
    exprs[0].push_back({});
    history[0] = {-1};
    ids[0] = {0};
    ll idc = 1;
    for(ll i = 0; i < N; i++) exprs[0][0].push_back(ps[i][0]);

    for(ll c = 1; c <= 9; c++) {

        for(ll i = 0; i < exprs[c-1].size(); i++) {
            vector<double> rs(N), rc(N);
            for(ll j = 0; j < N; j++) {
                rs[j] = sin(exprs[c-1][i][j]);
                rc[j] = cos(exprs[c-1][i][j]);
            }

            exprs[c].push_back(rs);
            ids[c].push_back(idc++);
            history.push_back({0, ids[c-1][i]});


            exprs[c].push_back(rc);
            ids[c].push_back(idc++);
            history.push_back({1, ids[c-1][i]});
        }


        for(ll nl = 0; nl <= c-2; nl++) {
            ll nr = c-2-nl;

            for(ll i1 = 0; i1 < exprs[nl].size(); i1++) {
                for(ll i2 = 0; i2 < exprs[nr].size(); i2++) {
                    const vector<double>& lhs = exprs[nl][i1];
                    const vector<double>& rhs = exprs[nr][i2];

                    vector<double> add(N), sub(N), mul(N), div(N); bool dgood = true;
                    for(ll j = 0; j < N; j++) {
                        add[j] = lhs[j]+rhs[j];
                        sub[j] = lhs[j]-rhs[j];
                        mul[j] = lhs[j]*rhs[j];
                        if(rhs[j]>=.01) div[j] = lhs[j]/rhs[j]; else dgood = false;
                    }


                    if(nl >= nr) {
                        exprs[c].push_back(add);
                        ids[c].push_back(idc++);
                        history.push_back({2, ids[nl][i1], ids[nr][i2]});

                        exprs[c].push_back(mul);
                        ids[c].push_back(idc++);
                        history.push_back({3, ids[nl][i1], ids[nr][i2]});
                    }
                    
                    exprs[c].push_back(sub);
                    ids[c].push_back(idc++);
                    history.push_back({4, ids[nl][i1], ids[nr][i2]});

                    if(dgood) {
                        exprs[c].push_back(div);
                        ids[c].push_back(idc++);
                        history.push_back({5, ids[nl][i1], ids[nr][i2]});
                    }
                }
            }

        }

    }

    for(ll i = 0; i < 10; i++) {
        for(ll j = 0; j < exprs[i].size(); j++) {
            double mx = 0;
            for(ll k = 0; k < N; k++) mx = max(mx, abs(exprs[i][j][k] - ps[k][1])/max(1.0, abs(ps[k][1])));
            if(mx <= 1e-3) {
                pprint(ids[i][j]); cout << "\n";
                return 0;
            }
        }
    }




}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 26ms
memory: 32680kb

input:

3
1.000000 1.000000
2.000000 4.000000
3.000000 9.000000

output:

(x*x)

result:

ok great!!

Test #2:

score: 0
Accepted
time: 29ms
memory: 42720kb

input:

3
0.618000 1.517072
0.314000 3.132637
1.414000 0.494016

output:

(sin(x)/(x*x))

result:

ok great!!

Test #3:

score: 0
Accepted
time: 15ms
memory: 25568kb

input:

5
77.685777 233.057331
-66.445083 -199.335249
79.966717 239.900151
84.982130 254.946390
-31.528900 -94.586700

output:

((x+x)+x)

result:

ok great!!

Test #4:

score: -100
Wrong Answer
time: 19ms
memory: 34864kb

input:

5
25.032427 -0.100652
38.727324 1.658518
27.684334 -0.669555
64.282391 8.275303
52.640700 -0.962660

output:


result:

wrong output format Unexpected end of file - token expected