QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#105623#6395. Equation Discoveringwoyouxiangbaile#WA 283ms89144kbC++144.5kb2023-05-14 15:50:512023-05-14 15:50:52

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:50:52]
  • 评测
  • 测评结果:WA
  • 用时:283ms
  • 内存:89144kb
  • [2023-05-14 15:50:51]
  • 提交

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 long double _epsn = 0.0000001, _epss = 0.000000001;
int n;
long double x[_maxn], y[_maxn];
struct node {
	int cp;
	long 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 + 1;
	rep(i, 0, n - 1) {
		re . da[i] = sin(da . da[i]);
	}
	return re;
}
node qcos(node da) {
	node re;
	re . cp = da . cp + 1;
	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]) > _epss) {
			return le . da[i] < ri . da[i];
		}
	}
	return 0;
}
set<node> sets;
bool pdif;
vector<int> dats[10];
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;
		}
		dats[atno . cp] . push_back(head);
		rep(i, 0, 7 - atno . cp) {
			for(int j : dats[i]) {
				if(!sets . count(tono = atno + queu[j])) {
					sets . insert(tono), queu[++tail] = tono, stat[tail] = 1, lson[tail] = head, rson[tail] = j;
				}
				if(!sets . count(tono = atno - queu[j])) {
					sets . insert(tono), queu[++tail] = tono, stat[tail] = 2, lson[tail] = head, rson[tail] = j;
				}
				if(!sets . count(tono = queu[j] - atno)) {
					sets . insert(tono), queu[++tail] = tono, stat[tail] = 2, lson[tail] = j, rson[tail] = head;
				}
				if(!sets . count(tono = atno * queu[j])) {
					sets . insert(tono), queu[++tail] = tono, stat[tail] = 3, lson[tail] = head, rson[tail] = j;
				}
				pdif = 1;
				rep(j, 0, n - 1) {
					if(fabs(queu[j] . da[j]) < _epsn) {
						pdif = 0;
						break;
					}
				}
				if(pdif && !sets . count(tono = atno / queu[j])) {
					sets . insert(tono), queu[++tail] = tono, stat[tail] = 4, lson[tail] = head, rson[tail] = j;
				}
				pdif = 1;
				rep(j, 0, n - 1) {
					if(fabs(atno . da[j]) < _epsn) {
						pdif = 0;
						break;
					}
				}
				if(pdif && !sets . count(tono = queu[j] / atno)) {
					sets . insert(tono), queu[++tail] = tono, stat[tail] = 4, lson[tail] = j, rson[tail] = head;
				}
			}
		}
		if(atno . cp <= 8 && !sets . count(tono = qsin(atno))) {
			sets . insert(tono), queu[++tail] = tono, stat[tail] = 5, lson[tail] = head;
		}
		if(atno . cp <= 8 && !sets . count(tono = qcos(atno))) {
			sets . insert(tono), queu[++tail] = tono, stat[tail] = 6, lson[tail] = head;
		}
	}
	return 0;
}

詳細信息

Test #1:

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

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: 283ms
memory: 89144kb

input:

3
0.618000 1.517072
0.314000 3.132637
1.414000 0.494016

output:


result:

wrong output format Unexpected end of file - token expected