QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372980#5271. Focusing on CostsFOY#WA 0ms3564kbC++231.7kb2024-03-31 22:08:482024-03-31 22:08:49

Judging History

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

  • [2024-03-31 22:08:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3564kb
  • [2024-03-31 22:08:48]
  • 提交

answer

#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
using pii = pair<int, int>;

class Trans {
	virtual string getName() = 0;
	virtual pii act(pii cur) = 0;
};

int transCount = 6;
pii act(pii cur, int type) {
	if (type == 0)
		return {cur.second - cur.first, cur.second};
	if (type == 1)
		return {cur.first, cur.second - cur.first};
	if (type == 2)
		return {cur.second - cur.first, cur.first};
	if (type == 3)
		return {cur.second - cur.first, cur.second};
	if (type == 4)
		return {cur.first, cur.second + cur.first};
	if (type == 5)
		return {cur.second, cur.first+cur.second};
}

string getName(int type) {
	if (type == 0) return "cos asin";
	if (type == 1) return "tan asin";
	if (type == 2) return "tan acos";
	if (type == 3) return "sin acos";
	if (type == 4) return "sin atan";
	if (type == 5) return "cos atan";
}


int main() {
	map<pii, pair<pii, int>> vis;
	queue<pii> cur;
	cur.push({0, 1});
	int a, b; cin >> a >> b;

	for (int i = 1; i <= min(a,b); i++) {
		if (a%i == 0 && b%i == 0) {
			a/=i;
			b/=i;
		}
	}

	while (vis.count({a*a, b*b}) == 0) {
		auto front = cur.front();
		cur.pop();
		if (front.first*front.first > 1e4 || front.second*front.second > 1e4) continue;
		for (int t = 0; t < transCount; t++) {
			auto to = act(front, t);
			if (vis.count(to) == 0) {
				vis[to] = {front, t};
				cur.push(to);
			}
		}
	}
	pii end = {a*a, b*b};
	vector<string> path;
	while (end != make_pair(0, 1)) {
		path.push_back(getName(vis[end].second));
		end = vis[end].first;
	}
	cout << 2*path.size() << endl;
	for (int i = path.size()-1; i >= 0; i--) cout << path[i]<< ' ';
	cout <<endl;
}


详细

Test #1:

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

input:

1 1

output:

2
cos asin 

result:

wrong answer Final result is 1.5707963268, expected 1.0000000000, absolute error = 0.5707963268