QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#105597#6395. Equation Discoveringwoyouxiangbaile#WA 1909ms10692kbC++144.4kb2023-05-14 15:02:532023-05-14 15:02:57

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-14 15:02:57]
  • 评测
  • 测评结果:WA
  • 用时:1909ms
  • 内存:10692kb
  • [2023-05-14 15:02:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i, d, u) for(int i = d; i <= u; ++i)
#define dep(i, u, d) for(int i = u; i >= d; --i)
#define cep(n) while(n--)
#define gep(i, a) for(int i = firs[a]; i; i = neig[i])
int ured() {
	int re = 0;
	char ch;
	do {
		ch = getchar();
	} while('9' < ch || ch < '0');
	do {
		re = re * 10 + (ch ^ '0');
	} while('0' <= (ch = getchar()) && ch <= '9');
	return re;
}
void uwit(int da) {
	int ch[21], cn = 0;
	do {
		ch[++cn] = da - da / 10 * 10;
	} while(da /= 10);
	do {
		putchar('0' ^ ch[cn]);
	} while(--cn);
}
const int _maxn = 20, _maxs = 5000011;
const double _epsn = 0.0001;
int n;
double x[_maxn], y[_maxn];
struct node {
	int cp;
	double da[_maxn];
} atno, queu[_maxs], tono;
node operator+(node le, node ri) {
	node re;
	re . cp = le . cp + ri . cp + 2;
	rep(i, 0, n - 1) {
		re . da[i] = le . da[i] + ri . da[i];
	}
	return re;
}
node operator-(node le, node ri) {
	node re;
	re . cp = le . cp + ri . cp + 2;
	rep(i, 0, n - 1) {
		re . da[i] = le . da[i] - ri . da[i];
	}
	return re;
}
node operator*(node le, node ri) {
	node re;
	re . cp = le . cp + ri . cp + 2;
	rep(i, 0, n - 1) {
		re . da[i] = le . da[i] * ri . da[i];
	}
	return re;
}
node operator/(node le, node ri) {
	node re;
	re . cp = le . cp + ri . cp + 2;
	rep(i, 0, n - 1) {
		re . da[i] = le . da[i] / ri . da[i];
	}
	return re;
}
node qsin(node da) {
	node re;
	re . cp = da . cp + 2;
	rep(i, 0, n - 1) {
		re . da[i] = sin(da . da[i]);
	}
	return re;
}
node qcos(node da) {
	node re;
	re . cp = da . cp + 2;
	rep(i, 0, n - 1) {
		re . da[i] = cos(da . da[i]);
	}
	return re;
}
int head, tail, stat[_maxs], lson[_maxs], rson[_maxs];
bool operator<(node le, node ri) {
	if(le . cp != ri . cp) {
		return le . cp < ri . cp;
	}
	rep(i, 0, n - 1) {
		if(fabs(le . da[i] - ri . da[i]) > _epsn) {
			return le . da[i] < ri . da[i];
		}
	}
	return 0;
}
set<node> sets;
bool pdif;
void outp(int at) {
	putchar('(');
	if(stat[at] == 1) {
		outp(lson[at]), putchar('+'), outp(rson[at]);
	} else if(stat[at] == 2) {
		outp(lson[at]), putchar('-'), outp(rson[at]);
	} else if(stat[at] == 3) {
		outp(lson[at]), putchar('*'), outp(rson[at]);
	} else if(stat[at] == 4) {
		outp(lson[at]), putchar('/'), outp(rson[at]);
	} else if(stat[at] == 5) {
		putchar('s'), putchar('i'), putchar('n'), outp(lson[at]);
	} else if(stat[at] == 6) {
		putchar('c'), putchar('o'), putchar('s'), outp(lson[at]);
	} else {
		putchar('x');
	}
	putchar(')');
}
int main() {
	n = ured();
	rep(i, 0, n - 1) {
		scanf("%lf%lf", &x[i], &y[i]), queu[1] . da[i] = x[i];
	}
	sets . insert(queu[++tail]);
	while(head < tail) {
		pdif = 1, atno = queu[++head];
		rep(i, 0, n - 1) {
			if(fabs(atno . da[i] - y[i]) > _epsn) {
				pdif = 0;
				break;
			}
		}
		if(pdif) {
			outp(head), putchar('\n');
			break;
		}
		rep(i, 1, head) {
			if(!sets . count(tono = atno + queu[i]) && tono . cp <= 9) {
				sets . insert(tono), queu[++tail] = tono, stat[tail] = 1, lson[tail] = head, rson[tail] = i;
			}
			if(!sets . count(tono = atno - queu[i]) && tono . cp <= 9) {
				sets . insert(tono), queu[++tail] = tono, stat[tail] = 2, lson[tail] = head, rson[tail] = i;
			}
			if(!sets . count(tono = queu[i] - atno) && tono . cp <= 9) {
				sets . insert(tono), queu[++tail] = tono, stat[tail] = 2, lson[tail] = i, rson[tail] = head;
			}
			if(!sets . count(tono = atno * queu[i]) && tono . cp <= 9) {
				sets . insert(tono), queu[++tail] = tono, stat[tail] = 3, lson[tail] = head, rson[tail] = i;
			}
			pdif = 1;
			rep(j, 0, n - 1) {
				if(fabs(atno . da[j]) < _epsn) {
					pdif = 0;
					break;
				}
			}
			if(pdif && !sets . count(tono = atno / queu[i]) && tono . cp <= 9) {
				sets . insert(tono), queu[++tail] = tono, stat[tail] = 4, lson[tail] = head, rson[tail] = i;
			}
			pdif = 1;
			rep(j, 0, n - 1) {
				if(fabs(queu[i] . da[j]) < _epsn) {
					pdif = 0;
					break;
				}
			}
			if(pdif && !sets . count(tono = queu[i] / atno) && tono . cp <= 9) {
				sets . insert(tono), queu[++tail] = tono, stat[tail] = 4, lson[tail] = i, rson[tail] = head;
			}
		}
		if(!sets . count(tono = qsin(atno)) && tono . cp <= 9) {
			sets . insert(tono), queu[++tail] = tono, stat[tail] = 5, lson[tail] = head;
		}
		if(!sets . count(tono = qcos(atno)) && tono . cp <= 9) {
			sets . insert(tono), queu[++tail] = tono, stat[tail] = 6, lson[tail] = head;
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 10072kb

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: 1ms
memory: 10260kb

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: 3ms
memory: 10080kb

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: 0
Accepted
time: 5ms
memory: 10384kb

input:

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

output:

((sin(x))/(cos(x)))

result:

ok great!!

Test #5:

score: -100
Wrong Answer
time: 1909ms
memory: 10692kb

input:

5
78.611917 -0.992212
-29.857271 1.011993
-75.513655 1.006611
68.512394 1.145128
7.961096 0.881661

output:


result:

wrong output format Unexpected end of file - token expected