QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#154805#7114. Best Interactive Playerucup-team368#AC ✓2ms3568kbC++206.9kb2023-08-31 23:31:222023-08-31 23:31:23

Judging History

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

  • [2023-08-31 23:31:23]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3568kb
  • [2023-08-31 23:31:22]
  • 提交

answer

#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA

void solve() {
    int lo = 1, hi = 1'000'000'000, mi;
    while (lo < hi) {
        mi = (lo + hi + 1) >> 1;
        cout << "? " << mi << "\n" << flush;
        int ret; cin >> ret;
        if (ret == 0) lo = mi;
        else          hi = mi - 1;
    }
    cout << "! " << lo << "\n";
}

int32_t main() {
    fastIO();
    
    int t = 1; // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
    
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define double __float80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;

// #define X first
// #define Y second
#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())

template <size_t D, typename T> struct Vec : vector<Vec<D-1, T>> {
    static_assert(D >= 1, "Vector dimension must be greater than zero!");
    template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D-1, T>>(n, Vec<D-1, T>(args...)) {}
};

template <typename T> struct Vec<1, T> : vector<T> {
    Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
};

template <class F>
inline constexpr decltype(auto) lambda_fix(F&& f) {
    return [f = std::forward<F>(f)](auto&&... args) {
        return f(f, std::forward<decltype(args)>(args)...);
    };
}

#ifdef local
#define fastIO() void()
#define debug(...) \
    _color.emplace_back("\u001b[31m"), \
    fprintf(stderr, "%sAt [%s], line %d: (%s) = ", _color.back().c_str(), __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), _color.pop_back(), \
    fprintf(stderr, "%s", _color.back().c_str())
deque<string> _color{"\u001b[0m"};

template <typename T> concept is_string = is_same_v<T, string&> or is_same_v<T, const string&>;
template <typename T> concept is_iterable = requires (T _t) {begin(_t);};

template <typename T> inline void _print_err(T &&_t);
template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>);
template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &);
template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t);
template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &);
template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t);
template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu);

inline void _do() {cerr << "\n";};
template <typename T> inline void _do(T &&_t) {_print_err(_t), cerr << "\n";}
template <typename T, typename ...U> inline void _do(T &&_t, U &&..._u) {_print_err(_t), cerr << ", ", _do(_u...);}
#else
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(...) void()
#endif

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int getRand(int L, int R) {
    if (L > R) swap(L, R);
    return (int)(rng() % ((uint64_t)R - L + 1) + L);
}

template <typename T, typename U> bool chmin(T &lhs, U rhs) {return lhs > rhs ? lhs = rhs, 1 : 0;}
template <typename T, typename U> bool chmax(T &lhs, U rhs) {return lhs < rhs ? lhs = rhs, 1 : 0;}

/// below are Fast I/O and _print_err templates ///

/*
/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///

#include <unistd.h>

const int S = 65536;

int OP = 0;
char OB[S];

inline char RC() {
    static char buf[S], *p = buf, *q = buf;
    return p == q and (q = (p = buf) + read(0, buf, S)) == buf ? -1 : *p++;
}

inline int RI() {
    static char c;
    int a;
    while (((c = RC()) < '0' or c > '9') and c != '-' and c != -1);
    if (c == '-') {
        a = 0;
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a -= c ^ '0';
    }
    else {
        a = c ^ '0';
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a += c ^ '0';
    }
    return a;
}

inline void WI(int n, char c = '\n') {
    static char buf[20], p;
    if (n == 0) OB[OP++] = '0';
    p = 0;
    if (n < 0) {
        OB[OP++] = '-';
        while (n) buf[p++] = '0' - (n % 10), n /= 10;
    }
    else {
        while (n) buf[p++] = '0' + (n % 10), n /= 10;
    }
    for (--p; p >= 0; --p) OB[OP++] = buf[p];
    OB[OP++] = c;
    if (OP > S-20) write(1, OB, OP), OP = 0;
}

/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///
*/

#ifdef local

template <typename T> inline void _print_err(T &&_t) {cerr << _t;}

template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>) {
    string _tmp_color = _color.back();
    ++_tmp_color[3], _color.emplace_back(_tmp_color);
    cerr << _color.back() << "[";
    for (bool _first = true; auto &_x : _t) {
        if (!_first) cerr << ", ";
        _print_err(_x), _first = false;
    }
    cerr << "]" << (_color.pop_back(), _color.back());
}

template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu) {
    string _tmp_color = _color.back();
    ++_tmp_color[3], _color.emplace_back(_tmp_color);
    cerr << _color.back() << "(";
    _print_err(_tu.first), cerr << ", ", _print_err(_tu.second);
    cerr << ")" << (_color.pop_back(), _color.back());
    return os;
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t) {
    if (!I) {
        string _tmp_color = _color.back();
        ++_tmp_color[3], _color.emplace_back(_tmp_color);
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t) {
    if (!I) {
        string _tmp_color = _color.back();
        ++_tmp_color[3], _color.emplace_back(_tmp_color);
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

#endif

#endif

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3504kb

input:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0

output:

? 500000001
? 250000001
? 125000001
? 62500001
? 31250001
? 15625001
? 7812501
? 3906251
? 1953126
? 976563
? 488282
? 244141
? 122071
? 61036
? 30518
? 15259
? 7630
? 3815
? 1908
? 954
? 477
? 239
? 120
? 60
? 30
? 15
? 8
? 4
? 2
? 3
! 3

result:

ok ok

Test #2:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

1
1
0
0
0
1
1
1
0
0
1
1
1
1
1
1
1
0
0
0
0
0
1
1
1
0
1
1
0
0

output:

? 500000001
? 250000001
? 125000001
? 187500001
? 218750001
? 234375001
? 226562501
? 222656251
? 220703126
? 221679688
? 222167969
? 221923828
? 221801758
? 221740723
? 221710205
? 221694946
? 221687317
? 221683502
? 221685409
? 221686363
? 221686840
? 221687078
? 221687197
? 221687137
? 221687107
...

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3460kb

input:

1
0
0
1
1
0
0
1
1
0
1
0
1
0
0
0
1
0
1
0
0
0
1
1
1
0
0
1
1
0

output:

? 500000001
? 250000001
? 375000001
? 437500001
? 406250001
? 390625001
? 398437501
? 402343751
? 400390626
? 399414063
? 399902344
? 399658203
? 399780273
? 399719238
? 399749755
? 399765014
? 399772643
? 399768828
? 399770735
? 399769781
? 399770258
? 399770496
? 399770615
? 399770555
? 399770525
...

result:

ok ok

Test #4:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

1
0
1
1
0
1
1
1
1
0
0
1
0
1
0
0
1
0
1
1
1
1
0
1
1
0
0
1
0
1

output:

? 500000001
? 250000001
? 375000001
? 312500001
? 281250001
? 296875001
? 289062501
? 285156251
? 283203126
? 282226563
? 282714844
? 282958985
? 282836914
? 282897949
? 282867431
? 282882690
? 282890319
? 282886504
? 282888411
? 282887457
? 282886980
? 282886742
? 282886623
? 282886682
? 282886652
...

result:

ok ok

Test #5:

score: 0
Accepted
time: 2ms
memory: 3400kb

input:

1
0
0
0
1
0
0
1
1
1
1
1
1
1
0
1
1
1
0
1
1
1
0
1
1
0
0
0
1
0

output:

? 500000001
? 250000001
? 375000001
? 437500001
? 468750001
? 453125001
? 460937501
? 464843751
? 462890626
? 461914063
? 461425782
? 461181641
? 461059571
? 460998536
? 460968018
? 460983277
? 460975647
? 460971832
? 460969925
? 460970878
? 460970401
? 460970163
? 460970044
? 460970103
? 460970073
...

result:

ok ok

Test #6:

score: 0
Accepted
time: 2ms
memory: 3452kb

input:

0
1
0
1
1
1
0
0
0
1
1
0
0
1
1
0
1
1
1
1
1
1
0
1
0
1
1
1
0
0

output:

? 500000001
? 750000001
? 625000001
? 687500001
? 656250001
? 640625001
? 632812501
? 636718751
? 638671876
? 639648438
? 639160157
? 638916016
? 639038086
? 639099121
? 639068603
? 639053344
? 639060973
? 639057158
? 639055251
? 639054297
? 639053820
? 639053582
? 639053463
? 639053522
? 639053492
...

result:

ok ok

Test #7:

score: 0
Accepted
time: 2ms
memory: 3388kb

input:

0
0
1
0
1
1
1
0
1
1
0
1
0
0
0
0
0
0
0
1
1
1
0
1
0
1
1
0
0
0

output:

? 500000001
? 750000001
? 875000001
? 812500001
? 843750001
? 828125001
? 820312501
? 816406251
? 818359376
? 817382813
? 816894532
? 817138672
? 817016602
? 817077637
? 817108154
? 817123413
? 817131042
? 817134857
? 817136764
? 817137718
? 817137241
? 817137002
? 817136883
? 817136942
? 817136912
...

result:

ok ok

Test #8:

score: 0
Accepted
time: 0ms
memory: 3368kb

input:

0
1
0
0
1
1
0
0
1
0
1
1
1
1
0
0
0
0
1
1
0
1
1
1
0
1
0
1
1
0

output:

? 500000001
? 750000001
? 625000001
? 687500001
? 718750001
? 703125001
? 695312501
? 699218751
? 701171876
? 700195313
? 700683594
? 700439453
? 700317383
? 700256348
? 700225830
? 700241089
? 700248718
? 700252533
? 700254440
? 700253486
? 700253009
? 700253247
? 700253128
? 700253068
? 700253038
...

result:

ok ok

Test #9:

score: 0
Accepted
time: 0ms
memory: 3428kb

input:

0
0
1
0
0
1
1
1
1
0
1
0
0
0
0
0
1
1
1
0
1
0
1
1
1
0
0
1
1
0

output:

? 500000001
? 750000001
? 875000001
? 812500001
? 843750001
? 859375001
? 851562501
? 847656251
? 845703126
? 844726563
? 845214844
? 844970703
? 845092773
? 845153808
? 845184326
? 845199585
? 845207214
? 845203399
? 845201492
? 845200538
? 845201015
? 845200776
? 845200895
? 845200835
? 845200805
...

result:

ok ok

Test #10:

score: 0
Accepted
time: 2ms
memory: 3456kb

input:

0
0
0
1
1
1
1
1
1
0
0
1
1
0
1
1
0
0
1
0
0
1
1
1
1
0
0
0
0
0

output:

? 500000001
? 750000001
? 875000001
? 937500001
? 906250001
? 890625001
? 882812501
? 878906251
? 876953126
? 875976563
? 876464844
? 876708985
? 876586914
? 876525879
? 876556396
? 876541137
? 876533508
? 876537322
? 876539229
? 876538275
? 876538752
? 876538990
? 876538871
? 876538811
? 876538781
...

result:

ok ok

Test #11:

score: 0
Accepted
time: 2ms
memory: 3432kb

input:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

output:

? 500000001
? 750000001
? 875000001
? 937500001
? 968750001
? 984375001
? 992187501
? 996093751
? 998046876
? 999023438
? 999511719
? 999755860
? 999877930
? 999938965
? 999969483
? 999984742
? 999992371
? 999996186
? 999998093
? 999999047
? 999999524
? 999999762
? 999999881
? 999999941
? 999999971
...

result:

ok ok

Test #12:

score: 0
Accepted
time: 2ms
memory: 3432kb

input:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

output:

? 500000001
? 250000001
? 125000001
? 62500001
? 31250001
? 15625001
? 7812501
? 3906251
? 1953126
? 976563
? 488282
? 244141
? 122071
? 61036
? 30518
? 15259
? 7630
? 3815
? 1908
? 954
? 477
? 239
? 120
? 60
? 30
? 15
? 8
? 4
? 2
! 1

result:

ok ok