QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#397810 | #6394. Turn on the Light | kinoko777 | WA | 1ms | 3728kb | C++20 | 1.9kb | 2024-04-24 17:10:43 | 2024-04-24 17:10:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> p11;
typedef pair<string, int> ps1;
typedef pair<ll, ll> p1111;
#define vv vector
#define pb emplace_back
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
// #define endl '\n'
// #define Endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define per(a, b, c) for(int a = b; a <= c; a ++)
#define rep(a, b, c) for(int a = b; a >= c; a --)
#define aper(A) for(auto i : A) cout << i << ' ';cout << '\n'
#define lowbit(x) ((x) & (-x))
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define PAI acos(-1)
using ll = long long;
#define double long double
void umin(int &x,int y){if(x>y)x=y;}
void umax(int &x,int y){if(x<y)x=y;}
const int mod = 1e9 + 7;
void add(int &x, int y){x = (x + y) % mod;}
void pre_work(){}
int ask(int x)
{
cout << "? " << x << endl;
int a;
cin >> a;
return a;
}
void pri(int x)
{
cout << "! " << x << endl;
}
void solve()
{
int n;
cin >> n;
int pre = 0;
for(int i = 1; i <= 10; i ++)
{
int now = ask(i);
if(now == pre)
{
pri(i);
return;
}
pre = now;
}
int l = pre, r = n;
while(l < r)
{
int mid = l + r >> 1;
int x = ask(mid);
if(x == pre)
{
pri(mid);
return;
}
else if(x > pre)
{
l = mid + 1;
}
else
{
r = mid - 1;
}
pre = x;
}
pri(l);
}
signed main()
{
IOS;
int tt = 1;
//cin >> tt;
pre_work();
while(tt --)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
10 1 2 3 4 5 6 7 8 8
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ! 9
result:
ok Correct position at 9
Test #3:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
9 1 2 3 4 5 6 7 7
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ! 8
result:
ok Correct position at 8
Test #4:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
8 1 2 3 4 5 6 6
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ! 7
result:
ok Correct position at 7
Test #5:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
7 1 2 3 4 5 5
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ! 6
result:
ok Correct position at 6
Test #6:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
6 1 2 3 4 5 5
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ! 6
result:
ok Correct position at 6
Test #7:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
5 1 2 3 3
output:
? 1 ? 2 ? 3 ? 4 ! 4
result:
ok Correct position at 4
Test #8:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
4 1 2 3 3
output:
? 1 ? 2 ? 3 ? 4 ! 4
result:
ok Correct position at 4
Test #9:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
3 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #10:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
2 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #11:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
1 0
output:
? 1 ! 1
result:
ok Correct position at 1
Test #12:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 11 10 11 12 11 12 13 14 15 14 15 16 17 18 17 18 19 20 19
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500005 ? 750003 ? 625004 ? 687503 ? 718753 ? 703128 ? 710940 ? 714846 ? 716799 ? 717776 ? 717287 ? 717531 ? 717653 ? 717714 ? 717745 ? 717729 ? 717737 ? 717741 ? 717743 ! 717742
result:
ok Correct position at 717742
Test #13:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
999999 1 2 3 4 5 6 7 8 9 10 11 10 11 12 11 12 13 14 15 14 15 16 17 18 17 18 19 20 19
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500004 ? 750002 ? 625003 ? 687502 ? 718752 ? 703127 ? 710939 ? 714845 ? 716798 ? 717775 ? 717286 ? 717530 ? 717652 ? 717713 ? 717744 ? 717728 ? 717736 ? 717740 ? 717742 ! 717741
result:
ok Correct position at 717741
Test #14:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
999998 1 2 3 4 5 6 7 8 9 10 11 12 13 14 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500004 ? 750001 ? 875000 ? 937499 ? 968749 ? 953124 ? 960936 ? 964842 ? 966795 ? 967772 ? 967283 ? 967527 ? 967649 ? 967710 ? 967741 ? 967725 ? 967733 ? 967737 ? 967739 ! 967738
result:
ok Correct position at 967738
Test #15:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
999997 1 2 3 4 5 6 7 8 9 10 11 12 13 14 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500003 ? 750000 ? 874999 ? 937498 ? 968748 ? 953123 ? 960935 ? 964841 ? 966794 ? 967771 ? 967282 ? 967526 ? 967648 ? 967709 ? 967740 ? 967724 ? 967732 ? 967736 ? 967738 ! 967737
result:
ok Correct position at 967737
Test #16:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
999996 1 2 3 4 5 6 7 8 9 10 11 10 11 12 11 12 13 14 15 14 15 16 17 18 17 18 19 20 19
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500003 ? 750000 ? 625001 ? 687500 ? 718750 ? 703125 ? 710937 ? 714843 ? 716796 ? 717773 ? 717284 ? 717528 ? 717650 ? 717711 ? 717742 ? 717726 ? 717734 ? 717738 ? 717740 ! 717739
result:
ok Correct position at 717739
Test #17:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
999995 1 2 3 4 5 6 7 8 9 10 11 10 11 12 11 12 13 14 15 14 15 16 17 18 17 18 19 20 19
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500002 ? 749999 ? 625000 ? 687499 ? 718749 ? 703124 ? 710936 ? 714842 ? 716795 ? 717772 ? 717283 ? 717527 ? 717649 ? 717710 ? 717741 ? 717725 ? 717733 ? 717737 ? 717739 ! 717738
result:
ok Correct position at 717738
Test #18:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
999994 1 2 3 4 5 6 7 8 9 10 11 12 13 14 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500002 ? 749998 ? 874996 ? 937495 ? 968745 ? 953120 ? 960932 ? 964838 ? 966791 ? 967768 ? 967279 ? 967523 ? 967645 ? 967706 ? 967737 ? 967721 ? 967729 ? 967733 ? 967735 ! 967734
result:
ok Correct position at 967734
Test #19:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
999993 1 2 3 4 5 6 7 8 9 10 11 12 13 14 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500001 ? 749997 ? 874995 ? 937494 ? 968744 ? 953119 ? 960931 ? 964837 ? 966790 ? 967767 ? 967278 ? 967522 ? 967644 ? 967705 ? 967736 ? 967720 ? 967728 ? 967732 ? 967734 ! 967733
result:
ok Correct position at 967733
Test #20:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
999992 1 2 3 4 5 6 7 8 9 10 11 10 11 12 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500001 ? 749997 ? 624999 ? 687498 ? 718747 ? 734372 ? 742184 ? 746090 ? 748043 ? 749020 ? 748531 ? 748775 ? 748897 ? 748958 ? 748989 ? 748973 ? 748981 ? 748985 ? 748987 ! 748986
result:
ok Correct position at 748986
Test #21:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
999991 1 2 3 4 5 6 7 8 9 10 11 10 11 12 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500000 ? 749996 ? 624998 ? 687497 ? 718746 ? 734371 ? 742183 ? 746089 ? 748042 ? 749019 ? 748530 ? 748774 ? 748896 ? 748957 ? 748988 ? 748972 ? 748980 ? 748984 ? 748986 ! 748985
result:
ok Correct position at 748985
Test #22:
score: -100
Wrong Answer
time: 1ms
memory: 3712kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500005 ? 250007 ? 125008 ? 62508 ? 31258 ? 15633 ? 7821 ? 3915 ? 1962 ? 985 ? 497 ? 741 ? 863 ? 924 ? 954 ? 969 ? 977 ? 981 ? 983 ! 984
result:
wrong answer Wrong favorite light!