QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#154045 | #7114. Best Interactive Player | ucup-team896# | AC ✓ | 2ms | 3660kb | C++23 | 7.4kb | 2023-08-31 13:03:42 | 2023-08-31 13:03:43 |
Judging History
answer
/*
* @Author: cmk666
* @Created time: 2023-08-31 13:01:42
* @Last Modified time: 2023-08-31 13:03:28
*/
#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
#ifdef LOCAL
#include"debug.h"
#else
#define D(...) ((void)0)
#endif
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
namespace FastIO
{
// ------------------------------
// #define IN_HAS_NEG
// #define OUT_HAS_NEG
// #define CHK_EOF
// #define DISABLE_MMAP
// ------------------------------
#if __cplusplus < 201400
#error Please use C++14 or higher.
#endif
#if __cplusplus > 201700
#define INLINE_V inline
#else
#define INLINE_V
#endif
#if ( defined(LOCAL) || defined(_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifndef DISABLE_MMAP
#include<sys/mman.h>
#endif
#ifdef LOCAL
inline char gc() { return getchar(); }
inline void pc(char c) { putchar(c); }
#else
#ifdef DISABLE_MMAP
INLINE_V constexpr int _READ_SIZE = 1 << 18;
INLINE_V static char _read_buffer[_READ_SIZE], *_read_ptr = nullptr, *_read_ptr_end = nullptr;
inline char gc()
{
if ( __builtin_expect(_read_ptr == _read_ptr_end, false) )
{
_read_ptr = _read_buffer;
_read_ptr_end = _read_buffer + fread(_read_buffer, 1, _READ_SIZE, stdin);
#ifdef CHK_EOF
if ( __builtin_expect(_read_ptr == _read_ptr_end, false) ) return EOF;
#endif
}
return *_read_ptr++;
}
#else
INLINE_V static const char *_read_ptr = (const char *)mmap(nullptr, INT_MAX, 1, 2, 0, 0);
inline char gc() { return *_read_ptr++; }
#endif
INLINE_V constexpr int _WRITE_SIZE = 1 << 18;
INLINE_V static char _write_buffer[_WRITE_SIZE], *_write_ptr = _write_buffer;
inline void pc(char c)
{
*_write_ptr++ = c;
if ( __builtin_expect(_write_buffer + _WRITE_SIZE == _write_ptr, false) )
{
fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout);
_write_ptr = _write_buffer;
}
}
INLINE_V struct _auto_flush
{
inline ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); }
} _auto_flush;
#endif
#ifdef CHK_EOF
inline constexpr bool _isdigit(char c) { return ( c & 16 ) && c != EOF; }
inline constexpr bool _isgraph(char c) { return c > 32 && c != EOF; }
#else
inline constexpr bool _isdigit(char c) { return c & 16; }
inline constexpr bool _isgraph(char c) { return c > 32; }
#endif
template < class T >
INLINE_V constexpr bool _is_integer = numeric_limits < T >::is_integer;
template < class T >
INLINE_V constexpr bool _is_signed = numeric_limits < T >::is_signed;
template < class T >
INLINE_V constexpr bool _is_unsigned = _is_integer < T > && !_is_signed < T >;
template <> INLINE_V constexpr bool _is_integer < __int128 > = true;
template <> INLINE_V constexpr bool _is_integer < __uint128_t > = true;
template <> INLINE_V constexpr bool _is_signed < __int128 > = true;
template <> INLINE_V constexpr bool _is_unsigned < __uint128_t > = true;
#undef INLINE_V
inline void read(char &c) { do c = gc(); while ( !_isgraph(c) ); }
inline void read_cstr(char *s)
{
char c = gc(); while ( !_isgraph(c) ) c = gc();
while ( _isgraph(c) ) *s++ = c, c = gc();
*s = 0;
}
inline void read(string &s)
{
char c = gc(); s.clear(); while ( !_isgraph(c) ) c = gc();
while ( _isgraph(c) ) s.push_back(c), c = gc();
}
#ifdef IN_HAS_NEG
template < class T, enable_if_t < _is_signed < T >, int > = 0 >
inline void read(T &x)
{
char c = gc(); bool f = true; x = 0;
while ( !_isdigit(c) ) { if ( c == 45 ) f = false; c = gc(); }
if ( f ) while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
else while ( _isdigit(c) ) x = x * 10 - ( c & 15 ), c = gc();
}
template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
inline void read(T &x)
{
char c = gc(); while ( !_isdigit(c) ) c = gc();
x = 0; while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
}
inline void write(char c) { pc(c); }
inline void write_cstr(const char *s) { while ( *s ) pc(*s++); }
inline void write(const string &s) { for ( char c : s ) pc(c); }
#ifdef OUT_HAS_NEG
template < class T, enable_if_t < _is_signed < T >, int > = 0 >
inline void write(T x)
{
char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
if ( x >= 0 ) do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
else { pc(45); do buffer[digits++] = -( x % 10 ) | 48, x /= 10; while ( x ); }
while ( digits ) pc(buffer[--digits]);
}
template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
inline void write(T x)
{
char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
while ( digits ) pc(buffer[--digits]);
}
template < int N > struct _tuple_io_helper
{
template < class ...T >
static inline void _read(tuple < T... > &x)
{ _tuple_io_helper < N - 1 >::_read(x), read(get < N - 1 > (x)); }
template < class ...T >
static inline void _write(const tuple < T... > &x)
{ _tuple_io_helper < N - 1 >::_write(x), pc(32), write(get < N - 1 > (x)); }
};
template <> struct _tuple_io_helper < 1 >
{
template < class ...T >
static inline void _read(tuple < T... > &x) { read(get < 0 > (x)); }
template < class ...T >
static inline void _write(const tuple < T... > &x) { write(get < 0 > (x)); }
};
template < class ...T >
inline void read(tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_read(x); }
template < class ...T >
inline void write(const tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_write(x); }
template < class T1, class T2 >
inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
template < class T1, class T2 >
inline void write(const pair < T1, T2 > &x) { write(x.first), pc(32), write(x.second); }
template < class T1, class ...T2 >
inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
template < class ...T >
inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
template < class T1, class ...T2 >
inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
template < class ...T >
inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
template < class T >
inline void print(const T &x) { write(x); }
inline void print_cstr(const char *x) { write_cstr(x); }
template < class T1, class ...T2 >
inline void print(const T1 &x, const T2 &...y) { print(x), pc(32), print(y...); }
template < class ...T >
inline void print_cstr(const char *x, const T *...y) { print_cstr(x), print_cstr(y...); }
inline void println() { pc(10); }
inline void println_cstr() { pc(10); }
template < class ...T >
inline void println(const T &...x) { print(x...), pc(10); }
template < class ...T >
inline void println_cstr(const T *...x) { print_cstr(x...), pc(10); }
}
using namespace FastIO;
int l = 1, r = (int)1e9, md, z;
int main()
{
while ( l < r )
{
md = ( l + r + 1 ) >> 1, cout << "? " << md << endl, cin >> z;
if ( z ) r = md - 1; else l = md;
}
return cout << "! " << l << endl, 0;
}
// 想上GM捏 想上GM捏 想上GM捏 想上GM捏 想上GM捏
// 伊娜可爱捏 伊娜贴贴捏
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3580kb
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: 0ms
memory: 3652kb
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: 2ms
memory: 3572kb
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: 2ms
memory: 3652kb
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: 3660kb
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: 1ms
memory: 3532kb
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: 3516kb
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: 1ms
memory: 3516kb
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: 2ms
memory: 3564kb
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: 0ms
memory: 3540kb
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: 3608kb
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: 1ms
memory: 3608kb
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