QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#242772 | #6395. Equation Discovering | ucup-team902 | WA | 1ms | 4192kb | C++17 | 1.3kb | 2023-11-07 17:00:01 | 2023-11-07 17:00:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define db double
#define va valarray<db>
#define mp make_pair
#define ep emplace_back
#define k(f) '(' + f + ')'
va X;
va Y;
void ins(vector<pair<string, va>> &arr, string f, va y){
if(abs(y - Y).max() <= 1e-3) printf("%s\n", f.c_str()), exit(0);
arr.ep(mp(f, y));
}
vector<pair<string, va>> e[10];
int main(){
int n; cin >> n;
X.resize(n);
Y.resize(n);
for(int i = 0; i < n; ++i){
cin >> X[i] >> Y[i];
}
ins(e[0], "x", X);
for(int i = 1; i <= 9; ++i){
for(auto &[f, y]: e[i - 1]){
ins(e[i], "sin" + k(f), sin(y));
ins(e[i], "cos" + k(f), cos(y));
}
for(int j = 0; j < i - 1; ++j){
for(auto &[f1, y1] : e[j]){
for(auto &[f2, y2] : e[i - j - 2]){
if(j >= i - j - 2){
ins(e[i], k(f1 + '+' + f2), y1 + y2);
ins(e[i], k(f1 + '*' + f2), y1 * y2);
}
ins(e[i], k(f1 + '-' + f2), y1 - y2);
if(abs(y2).min() >= 0.01){
ins(e[i], k(f1 + '/' + f2), y1 / y2);
}
}
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4192kb
input:
3 1.000000 1.000000 2.000000 4.000000 3.000000 9.000000
output:
(x*x)
result:
ok great!!
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 4176kb
input:
3 0.618000 1.517072 0.314000 3.132637 1.414000 0.494016
output:
(ng::_M_construct null not validx)/(x*x))
result:
wrong answer Token parameter [name=out-expr] equals to "(ng::_M_construct", doesn't correspond to pattern "[\+\-*/sincox\(\)]{1,1000}"