QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372992#5271. Focusing on CostsFOY#WA 1ms3772kbC++231.6kb2024-03-31 22:28:452024-03-31 22:28:45

Judging History

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

  • [2024-03-31 22:28:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3772kb
  • [2024-03-31 22:28:45]
  • 提交

answer

#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <numeric>
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) {
	auto [a, b] = cur;
	if (type == 0)
		return {b - a, b};
	if (type == 1)
		return {a, b - a};
	if (type == 2)
		return {b - a, a};
	if (type == 3)
		return {b - a, b};
	if (type == 4)
		return {a, b + a};
	if (type == 5)
		return {b, a+b};
}

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


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

			int a = x, b = y;
			cout << a << ' ' << b << endl;
			int u = gcd(a,b);
			a/=u;
			b/=u;

	while (vis.count({a*a, b*b}) == 0) {
		auto front = cur.front();
		cur.pop();
		if (abs(front.first) > 1e3 || abs(front.second) > 1e3) continue;
		for (int t = 0; t < transCount; t++) {
			auto to = act(front, t);
			if (to.second <= 0) continue;
			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: 1ms
memory: 3772kb

input:

1 1

output:

1 1
2
asin cos 

result:

wrong answer Token parameter [name=op[1]] equals to "1", doesn't correspond to pattern "a?(sin|cos|tan)"