QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#378758#6394. Turn on the LightAprilend#WA 1ms3708kbC++141.5kb2024-04-06 14:31:522024-04-06 14:31:53

Judging History

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

  • [2024-04-06 14:31:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-04-06 14:31:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define edl '\n'
#define re return
#define gcd __gcd
#define db double
#define fir first
#define sec second
#define MAX 1000006
#define ll long long
#define i64 __int128
#define inf 2147483647
#define MAXN 100000009 
#define pll pair<ll,ll>
#define pb push_back
#define vint vector<int>
#define pii pair<int,int>
#define ANS cout<<ans<<edl
#define No cout<<"No"<<edl
#define NO cout<<"NO"<<edl
#define hhh cout<<"hhh"<<edl
#define Yes cout<<"Yes"<<edl
#define YES cout<<"YES"<<edl
#define all(a,l,r) a+l,a+1+r
#define ull unsigned long long
#define INF 9223372036854775807
#define vpii vector<pair<int,int>>
#define sp(x) fixed << setprecision(x)
#define FOR(i,l,r) for(auto(i)=(l);(i)<=(r);++(i))
const ll mod = 1000000007;
ll qpow(ll n,ll m,ll mod)
{
	ll ans=1;if(n>mod) n%=mod;
	while(m>0){if(m&1) {ans*=n;ans%=mod;}
	n*=n; n%=mod; m>>=1;} return ans;
}

void Solve(void)
{
	int n; cin>>n;
	int l=1, r=n, mid=l+r>>1, ans, pre=0;
	FOR(i,1,20) {
		cout<<"? "<<i<<endl;
		cin>>ans;
		if(ans==pre) {
			cout<<"! "<<i<<endl;
			re;
		}
		pre=ans;
	}
	l=21;
	while(l <= r) {
        ll mid = l + r >> 1;
		cout<<"? "<<mid<<endl;
		cin>>ans;
		if(ans==pre) {
			cout<<"! "<<1<<endl;
			re;
		}
		else if(ans>pre) {
			l=mid+1;
		}
		else if(ans<mid) {
			r=mid-1;
		}
		pre=ans;
    }
}
int main(void)
{
	std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int _=1;
	// cin>>_;
	while(_--)
    Solve ();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3708kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

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: 0ms
memory: 3708kb

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: 0ms
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: 3656kb

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: 3572kb

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: 1ms
memory: 3592kb

input:

5
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #8:

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

input:

4
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

score: -100
Wrong Answer
time: 1ms
memory: 3588kb

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
22
23
24
25
26
27
28
29
30
31
32
31
32
31
32
33
33

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 15
? 16
? 17
? 18
? 19
? 20
? 500010
? 750005
? 875003
? 937502
? 906252
? 921877
? 929689
? 933595
? 935548
? 936525
? 937013
? 937257
? 937379
? 937440
? 937471
? 937455
? 937463
? 937459
? 937461
? 937462
! 1

result:

wrong answer Wrong favorite light!