QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#155802 | #7114. Best Interactive Player | ucup-team296 | AC ✓ | 2ms | 3572kb | C++20 | 1.4kb | 2023-09-02 06:37:13 | 2023-09-02 06:37:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../debug.h"
#else
#define dbg(...) 787788
#endif
void solve() {
// ask y
// 1 -> x < y
int l = 1, r = 1e9 + 1;
while (r - l > 1) {
int m = (l + r) >> 1;
cout << "? " << m << endl;
int res;
cin >> res;
assert(res == 0 || res == 1);
if (res == 1) {
r = m;
} else {
l = m;
}
}
cout << "! " << l << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifdef LOCAL
#include <filesystem>
int tests = 0;
for (const auto &entry : std::filesystem::directory_iterator("tests")) {
const string path = entry.path();
int len = path.size();
if (len < 3 || path.substr(len - 3) != ".in") {
continue;
}
if (path != "tests/1.in") {
// continue;
}
std::cout << "\u001b[31m" << path << "\u001b[0m" << std::endl;
std::ifstream f(path);
if (f.is_open())
std::cout << "input:\n"
<< f.rdbuf() << "\n\noutput:\n";
freopen(path.c_str(), "r", stdin);
solve();
cout << "\n\n";
tests += 1;
}
if (tests == 0) {
solve();
}
#else
solve();
#endif
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3336kb
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: 3432kb
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: 1ms
memory: 3436kb
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: 3564kb
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: 3372kb
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: 3424kb
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: 3436kb
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: 2ms
memory: 3564kb
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: 3512kb
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: 3572kb
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: 1ms
memory: 3524kb
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: 3340kb
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