QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#414418#6749. TargetOneWanWA 64ms20584kbC++231.2kb2024-05-18 22:58:442024-05-18 22:58:45

Judging History

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

  • [2024-05-18 22:58:45]
  • 评测
  • 测评结果:WA
  • 用时:64ms
  • 内存:20584kb
  • [2024-05-18 22:58:44]
  • 提交

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;
			while (pre.count(b)) {
				ans.push_back(pre[b][1]);
				b = pre[b][0];
			}
			reverse(begin(ans), end(ans));
			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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3864kb

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

1 0.75

output:

12

result:

ok ok

Test #3:

score: -100
Wrong Answer
time: 64ms
memory: 20584kb

input:

1 0

output:


result:

wrong answer wa