QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#414414#6749. TargetOneWanWA 0ms3788kbC++231.1kb2024-05-18 22:56:252024-05-18 22:56:25

Judging History

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

  • [2024-05-18 22:56:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2024-05-18 22:56:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int __OneWan_2024 = [](){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	return 0;
}();
map<double, int> dist;
map<double, array<double, 2>> pre;
int main() {
	double a, b;
	cin >> a >> b;
	dist[a] = 0;
	queue<double> que;
	que.push(a);
	while (!que.empty()) {
		double x = que.front();
		que.pop();
		if (fabs(x - b) < 1e-5) {
			vector<int> ans;
			double now = b;
			while (pre.count(b)) {
				ans.push_back(pre[b][1]);
				b = pre[b][0];
			}
			for (auto &x : ans) {
				cout << x;
			}
			break;
		}
		{
			double tx = x * 0.5;
			if (!dist.count(tx)) {
				dist[tx] = dist[x] + 1;
				pre[tx] = {x, 1};
				que.push(tx);
			} else {
				if (dist[tx] > dist[x] + 1) {
					dist[tx] = dist[x] + 1;
					pre[tx] = {x, 1};
					que.push(tx);
				}
			}
		}
		{
			double tx = (x + 1) / 2;
			if (!dist.count(tx)) {
				dist[tx] = dist[x] + 1;
				pre[tx] = {x, 2};
				que.push(tx);
			} else {
				if (dist[tx] > dist[x] + 1) {
					dist[tx] = dist[x] + 1;
					pre[tx] = {x, 2};
					que.push(tx);
				}
			}
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3788kb

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3716kb

input:

1 0.75

output:

21

result:

wrong answer wa