QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#409249 | #6749. Target | yzh_whs# | WA | 2ms | 3996kb | C++20 | 1.4kb | 2024-05-11 20:50:31 | 2024-05-11 20:50:32 |
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;
}
};
bool f;
double a,b;
map<double,bool> vis;
void dfs(double u,string s=""){
// cout<<u<<endl;
if(f)return;
if(abs(u-b)<p){
cout<<s<<endl;
f=true;
return;
}
if(u<p&&u!=0)return;
if(abs(u)>1-p&&u!=1)return;
if(s.size()>50)return;
if(!vis[u/2]){
vis[u/2]=true;
dfs(u/2,s+'1');
vis[u/2]=false;
}
if(!vis[(u-1)/2+1]){
vis[(u-1)/2+1]=true;
dfs((u-1)/2+1,s+'2');
vis[(u-1)/2+1]=false;
}
}
int main() {
cin>>a>>b;
// queue<Node> q;
// q.push({a});
// vis[a]=true;
// while(!q.empty()){
// Node now=q.front();q.pop();
// mp[now.num]=true;
// if(now.s.size()>50)continue;
// 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;
// }
// }
dfs(a);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3720kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
1 0.75
output:
11111111111112111111111111211111111111122
result:
ok ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3868kb
input:
1 0
output:
11111111111111
result:
ok ok
Test #4:
score: 0
Accepted
time: 2ms
memory: 3996kb
input:
0.361954 0.578805
output:
11111111111211111111111121111111111112121111212112
result:
ok ok
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 3996kb
input:
0.144888 0.140086
output:
111111111121111111111112111111111111211122222111211
result:
wrong answer wa