QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#409224 | #6749. Target | yzh_whs# | TL | 1ms | 4008kb | C++20 | 780b | 2024-05-11 20:38:34 | 2024-05-11 20:38:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define p 1e-4
struct Node{
double num;
string s;
bool operator<(const Node&b)const{
return num<b.num;
}
};
double a,b;
map<double,bool> mp;
int main() {
cin>>a>>b;
queue<Node> q;
q.push({a});
mp[a]=true;
while(!q.empty()){
Node now=q.front();q.pop();
mp[now.num]=true;
if(abs(now.num-b)<p){
cout<<now.s<<endl;
break;
}
if(!mp[now.num/2]){
q.push({now.num/2,now.s+'1'});
mp[now.num/2]=true;
}
if(!mp[(now.num-1)/2+1]){
q.push({1-now.num/2,now.s+'2'});
mp[1-now.num/2]=true;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3668kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
1 0.75
output:
12
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 4008kb
input:
1 0
output:
11111111111111
result:
ok ok
Test #4:
score: -100
Time Limit Exceeded
input:
0.361954 0.578805