QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#414407 | #6749. Target | OneWan | WA | 1ms | 3692kb | C++23 | 1.1kb | 2024-05-18 22:49:03 | 2024-05-18 22:49:05 |
Judging History
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);
pre[a] = {-1, -1};
while (!que.empty()) {
double x = que.front();
que.pop();
if (fabs(x - b) < 1e-5) 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);
}
}
}
}
vector<int> ans;
double now = b;
while (pre[b][0] != -1) {
ans.push_back(pre[b][1]);
b = pre[b][0];
}
for (auto &x : ans) {
cout << x;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3692kb
input:
1 0.75
output:
21
result:
wrong answer wa