QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#403444 | #6749. Target | ccsu_zx# | WA | 2ms | 5128kb | C++14 | 1.3kb | 2024-05-02 13:15:47 | 2024-05-02 13:15:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 998244353;
const int N = 1e5+10;
int dis[N];
int p[N];
int path[N];
void solve() {
// string sa, sb;
double sa, sb;
int a = 0, b = 0;
int i, j;
cin>>sa>>sb;
// if (sa.size() == 1) {
// a = sa[0];
// i = 2;
// }
// else {
// for (i = 2; i < sa.size(); i++) {
// a = a*10 + sa[i]-'0';
// }
// }
// while (i < sb.size()) {
// a = a*10;
// i++;
// }
//
// if (sb.size() == 1) {
// b = sb[0];
// i = 2;
// } else {
// for (i = 2; i < sb.size(); i++) {
// b = b*10 + sb[i]-'0';
// }
// }
// while (i < sa.size()) {
// b = b*10;
// i++;
// }
a = sa*1e5, b = sb*1e5;
// printf("a = %d, b= %d\n", a, b);
memset(dis, -1, sizeof(dis));
queue<int> q;
q.push(a);
dis[a] = 0;
while (!q.empty()) {
int u = q.front();
q.pop();
// printf("u = %d\n", u);
int v = u/2;
if (dis[v] == -1) {
p[v] = u;
path[v] = 1;
dis[v] = dis[u]+1;
q.push(v);
}
v = u/2 + 0.5*1e5;
if (dis[v] == -1) {
p[v] = u;
path[v] = 2;
dis[v] = dis[u]+1;
q.push(v);
}
}
while (b != a) {
// printf("b = %d\n", b);
cout<<path[b];
b = p[b];
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
// cin>>T;
while (T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 5128kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 5024kb
input:
1 0.75
output:
21
result:
wrong answer wa