| Task: | Huippualkio |
| Sender: | jlaire |
| Submission time: | 2025-11-07 18:44:45 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #5 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #6 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #7 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #8 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
| #9 | ACCEPTED | 0.02 s | 2, 3 | details |
| #10 | ACCEPTED | 0.01 s | 2, 3 | details |
| #11 | ACCEPTED | 0.02 s | 2, 3 | details |
| #12 | ACCEPTED | 0.02 s | 2, 3 | details |
| #13 | ACCEPTED | 0.01 s | 2, 3 | details |
| #14 | WRONG ANSWER | 0.02 s | 2, 3 | details |
| #15 | WRONG ANSWER | 0.18 s | 3 | details |
| #16 | WRONG ANSWER | 0.18 s | 3 | details |
| #17 | WRONG ANSWER | 0.25 s | 3 | details |
| #18 | WRONG ANSWER | 0.47 s | 3 | details |
| #19 | WRONG ANSWER | 0.37 s | 3 | details |
| #20 | WRONG ANSWER | 0.37 s | 3 | details |
| #21 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #22 | ACCEPTED | 0.02 s | 2, 3 | details |
| #23 | WRONG ANSWER | 0.40 s | 3 | details |
| #24 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #25 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #26 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #27 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #28 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #29 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #30 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #31 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
Code
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
using namespace std;
using Q = function<int(int)>;
map<int,int> CACHE;
int query_io(int pos) {
if (CACHE.count(pos)) return CACHE[pos];
cout << "? " << pos << endl;
int x; cin>>x;
return CACHE[pos]=x;
}
bool lmax(int pos, Q q) {
return q(pos) >= max(q(pos-1), q(pos+1));
}
int solve_brute(int L, int R, Q q) {
for (int i=L+1; i<R; i++)
if (lmax(i,q)) return i;
return lmax(L,q) ? L : R;
}
int solve(int L, int R, Q q) {
if (L==R) {
return L;
}
if (R-L<=5) {
return solve_brute(L,R,q);
}
// L ... A ... B ... R
int A = L + (R-L)/3;
int B = A + (R-L)/3;
if (q(A)>=max(q(L),q(B))) {
return solve(L,B,q);
}
return solve(A,R,q);
}
int main() {
int n; cin>>n;
int ans = solve(1, n, [=](int pos) {
if (pos<=0 || pos>n) return -1;
return query_io(pos);
});
cout << "! " << ans << endl;
}
Test details
Test 1 (public)
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 8 5 2 4 1 3 3 2 4 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 8 ? 3 4 ? 5 3 ... |
Error:
1 1 100 0
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1 1 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 1 ! 1 |
Error:
1 1 100 0
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 50 ? 17 1 ? 33 1 ... |
Error:
1 1 100 0
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 50 2 1 2 2 2 2 1 1 1 1 2 1 1 2 2 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 50 ? 17 1 ? 33 1 ... |
Error:
1 1 100 0
Test 5
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 50 657 448 315 782 966 983 560 32... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 50 ? 17 451 ? 33 88 ... |
Error:
1 1 100 0
Test 6
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 50 541463939 624015614 406717194 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 50 ? 17 574417829 ? 33 688380735 ... |
Error:
1 1 100 0
Test 7
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 50 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 50 ? 17 17 ? 33 33 ... |
Error:
1 1 100 0
Test 8
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 50 50 49 48 47 46 45 44 43 42 41 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 50 ? 17 34 ? 33 18 ... |
Error:
1 1 101 0
Test 9
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 100 ? 34 1 ? 67 1 ... |
Error:
1 1 100 0
Test 10
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 1 2 2 1 2 1 1 2 2 1 2 2 1 1 2 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 100 ? 34 1 ? 67 2 ... |
Error:
1 1 100 0
Test 11
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 401 388 765 398 183 79 268 339... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 100 ? 34 955 ? 67 930 ... |
Error:
1 1 100 0
Test 12
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 34030354 571736161 659501910 9... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 100 ? 34 685097645 ? 67 337502849 ... |
Error:
1 1 100 0
Test 13
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 100 ? 34 34 ? 67 67 ... |
Error:
1 1 100 0
Test 14
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 100 100 99 98 97 96 95 94 93 92 91... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 100 ? 34 67 ? 67 34 ... |
Error:
1 1 101 0
Test 15
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 1000000 ? 333334 1 ? 666667 1 ... |
Error:
1 1 101 0
Test 16
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 2 1 1 2 2 2 2 1 2 1 1 1 1 1 1 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 1000000 ? 333334 1 ? 666667 2 ... |
Error:
1 1 101 0
Test 17
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 338 877 986 388 699 868 559 99... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 1000000 ? 333334 589 ? 666667 935 ... |
Error:
1 1 101 0
Test 18
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 301892461 304390263 250772451 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 1000000 ? 333334 381341657 ? 666667 683925354 ... |
Error:
1 1 101 0
Test 19
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 1000000 ? 333334 333334 ? 666667 666667 ... |
Error:
1 1 101 0
Test 20
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 1000000 999999 999998 999997 9... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 1000000 ? 333334 666667 ? 666667 333334 ... |
Error:
1 1 101 0
Test 21
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 50 1000000 1000001 1000002 100000... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 50 ? 17 1000016 ? 33 1000028 ... |
Error:
1 1 100 0
Test 22
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 1000000 1000001 1000002 100000... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 100 ? 34 1000025 ? 67 999992 ... |
Error:
1 1 100 0
Test 23
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 1000000 1000001 1000002 100000... |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 1000000 ? 333334 1333333 ? 666667 1081158 ... |
Error:
1 1 101 0
Test 24
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1 1000000000 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 1 ! 1 |
Error:
1 1 100 0
Test 25
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 2 1 1 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 2 ? 1 1 ? 2 1 ... |
Error:
1 1 100 0
Test 26
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 2 1 2 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 2 ? 1 1 ? 2 2 ... |
Error:
1 1 100 0
Test 27
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 2 2 1 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 2 ? 1 2 ? 2 1 ... |
Error:
1 1 100 0
Test 28
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 3 1 1 1 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 3 ? 2 1 ? 3 1 ... |
Error:
1 1 100 0
Test 29
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 3 1 1 2 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 3 ? 2 1 ? 3 2 ... |
Error:
1 1 100 0
Test 30
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 3 1 2 1 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 3 ? 2 2 ? 3 1 ... |
Error:
1 1 100 0
Test 31
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 3 2 1 1 |
| correct output |
|---|
| (empty) |
| user output |
|---|
| 3 ? 2 1 ? 3 1 ... |
Error:
1 1 100 0
