QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#300948#5471. Interactive Number GuessingELDRVDWA 1ms3680kbC++141.3kb2024-01-09 02:57:042024-01-09 02:57:04

Judging History

This is the latest submission verdict.

  • [2024-01-09 02:57:04]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3680kb
  • [2024-01-09 02:57:04]
  • Submitted

answer

//https://qoj.ac/contest/1101/problem/5471
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define PI acos(-1)
#define LSB(i) ((i) & -(i))
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define INF 1e18
#define MOD 1000000007
#define endl "\n"

#define all(data)       data.begin(),data.end()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
ll dd,mm,mm1,mm2;
int main()
{
    //ios::sync_with_stdio(false); cin.tie(0);
    cout<<"query 0"<<endl; cin>>mm;
    if(mm==0) {cout<<"answer 0"<<endl; return 0;}
    for(ll i=1; i<INF;i*=10)
    {
        ll l=1,r=10,mid;
        while(l<r)
        {
            mid=(l+r)/2;
            cout<<"query "<<dd+i*mid<<endl; cin>>mm1;
            if(mm1==mid+mm) l=mid+1;
            else r=mid;
            if(r==mid) mm2=mm1;
        }
        if(l==10) {l=0; cout<<"query "<<dd<<endl; cin>>mm2;}
        dd+=i*l; mm=mm2;
    }
    cout<<"answer "<<INF-dd<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3680kb

input:

6
11
5
4
12
9
3
2
10
7
1
9
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1
6
9
1

output:

query 0
query 5
query 8
query 7
query 6
query 57
query 87
query 77
query 67
query 577
query 877
query 777
query 5877
query 8877
query 9877
query 59877
query 89877
query 99877
query 599877
query 899877
query 999877
query 5999877
query 8999877
query 9999877
query 59999877
query 89999877
query 99999877...

result:

wrong answer wrong guess: 128  actual: 123