QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#409224#6749. Targetyzh_whs#TL 1ms4008kbC++20780b2024-05-11 20:38:342024-05-11 20:38:35

Judging History

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

  • [2024-05-11 20:38:35]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:4008kb
  • [2024-05-11 20:38:34]
  • 提交

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

output:


result: