QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#300947 | #5471. Interactive Number Guessing | ELDRVD | TL | 0ms | 0kb | C++14 | 1.3kb | 2024-01-09 02:55:50 | 2024-01-09 02:55:50 |
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
Time Limit Exceeded