QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#555191#5471. Interactive Number GuessingevirirWA 1ms3536kbC++20977b2024-09-09 20:31:082024-09-09 20:31:08

Judging History

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

  • [2024-09-09 20:31:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3536kb
  • [2024-09-09 20:31:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
using ll = long long;
using ii = pair<ll, ll>;
using ld = long double;

ll query(ll x)
{
    cout<<"query "<<x<<endl;
    ll r; cin>>r;
    return r;
}

ll answer(ll x)
{
    cout<<"answer "<<x<<endl;
    exit(0);
}

int main()
{
    ll b = 1;
    ll ans = 0;
    ll ori = query(0);
    forn(i,0,2)
    {
        ll ba = 0;
        for (int L = 1, R = 9; L <= R; )
        {
            ll mid = (L + R) / 2;
            ll r = query(b * (10 - mid));
            if (r < ori + (10 - mid))
            {
                ba = mid;
                L = mid + 1;
            }
            else R = mid - 1;
        }
        ans += ba * b;
        b *= 10;
    }
    answer(ans);

    return 0;
}

詳細信息

Test #1:

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

input:

6
11
5
4
12
11
5
13

output:

query 0
query 5
query 8
query 7
query 6
query 50
query 80
query 70
answer 23

result:

wrong answer wrong guess: 23  actual: 123