QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#105195#6396. Puzzle: KusabiSommohito#WA 0ms4100kbC++204.2kb2023-05-13 16:05:322023-05-13 16:05:34

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-13 16:05:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4100kb
  • [2023-05-13 16:05:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef APURBA
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define ALL(x) x.begin(),x.end()

const int N = 2e5 +5;
typedef pair<int,int> pii;

//int cnt(int comp)
//{
//    ll ans=0;
//
//    if(comp-2>=0)
//    {
//        int baki=comp-2;
//        for(int l=0;l<=baki;l++)
//        {
//            int L=cnt(l);
//            int R=cnt(baki-l);
//            ans+=L*R*4;
//        }
//    }
//    if(comp-1>=0)
//    {
//        ans+=cnt(comp-1)*2;
//    }
//    ans++;
//
//    return ans;
//}
vector<ld> x,y;
vector<pair<vector<ld>,string>> save[10];
int dp[10];
int n;

vector<pair<vector<ld>,string>> cnt(int comp)
{
    if(dp[comp])
        return save[comp];
    dp[comp]=true;

    vector<pair<vector<ld>,string>> ans;

    if(comp-2>=0)
    {
        int baki=comp-2;
        for(int l=0; l<=baki; l++)
        {
            auto L=cnt(l);
            auto R=cnt(baki-l);
            for(auto l:L)
            {
                for(auto r:R)
                {
                    {
                        pair<vector<ld>,string> notun;
                        notun.first.resize(n);
                        notun.second="("+l.second+"+"+r.second+")";
                        for(int i=0; i<n; i++)
                            notun.first[i]=l.first[i]+r.first[i];
                        ans.push_back(notun);
                    }
                    {
                        pair<vector<ld>,string> notun;
                        notun.first.resize(n);
                        notun.second="("+l.second+"-"+r.second+")";
                        for(int i=0; i<n; i++)
                            notun.first[i]=l.first[i]-r.first[i];
                        ans.push_back(notun);
                    }
                    {
                        pair<vector<ld>,string> notun;
                        notun.first.resize(n);
                        notun.second="("+l.second+"*"+r.second+")";
                        for(int i=0; i<n; i++)
                            notun.first[i]=l.first[i]*r.first[i];
                        ans.push_back(notun);
                    }

                    {
                        pair<vector<ld>,string> notun;
                        notun.first.resize(n);
                        notun.second="("+l.second+"/"+r.second+")";
                        bool f=1;
                        for(int i=0; i<n; i++)
                        {
                            if(abs(r.first[i])<0.01) f=0;
                            notun.first[i]=l.first[i]/r.first[i];
                        }
                        if(f)
                            ans.push_back(notun);
                    }
                }
            }
        }
    }
    if(comp-1>=0)
    {
        auto L=cnt(comp-1);

        for(auto l:L)
        {
            {
                pair<vector<ld>,string> notun;
                notun.first.resize(n);
                notun.second="sin("+l.second+")";
                for(int i=0; i<n; i++)
                    notun.first[i]=sin(l.first[i]);
                ans.push_back(notun);
            }
            {
                pair<vector<ld>,string> notun;
                notun.first.resize(n);
                notun.second="cos("+l.second+")";
                for(int i=0; i<n; i++)
                    notun.first[i]=cos(l.first[i]);
                ans.push_back(notun);
            }
        }

    }
    ans.push_back({x,"x"});

    return save[comp]=ans;
}
void TEST_CASES()
{
    cin>>n;
    x.resize(n);
    y.resize(n);
    for(int i=0; i<n; i++)
        cin>>x[i]>>y[i];
    for(int comp=0;comp<=9;comp++)
    {
        auto got=cnt(comp);
        for(auto r:got)
        {
            bool f=1;
            for(int i=0;i<n;i++)
            {
                if(abs(y[i]-r.first[i])>=1e-3)
                    f=0;
            }
            if(f)
            {
                cout<<r.second;
                exit(0);
            }
        }
    }
}




/*
*/

int32_t main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    //freopen("input.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        TEST_CASES();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8
2 1 -
3 1 -
4 2 Tong
5 2 Tong
6 3 Duan
7 3 -
8 7 Chang

output:

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

result:

wrong answer YES or NO expected in answer, but SIN((X*SIN(SIN(X)))) found.