QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#409249#6749. Targetyzh_whs#WA 2ms3996kbC++201.4kb2024-05-11 20:50:312024-05-11 20:50:32

Judging History

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

  • [2024-05-11 20:50:32]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3996kb
  • [2024-05-11 20:50:31]
  • 提交

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