QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#218021#6394. Turn on the LightCRN2010WA 1ms3648kbC++201.2kb2023-10-17 17:24:352023-10-17 17:24:35

Judging History

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

  • [2023-10-17 17:24:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3648kb
  • [2023-10-17 17:24:35]
  • 提交

answer

#include <bits/stdc++.h>
#define int unsigned long long 
#define ls (x << 1) 
#define rs (x << 1 | 1 )
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(x,y,z) for(int x = (y) ; x <= z ; ++x ) 
#define FOR_(x,y,z) for(int x = (y) ; x >= z ; --x )
#define all(x) x.begin(),x.end()
//#define endl '\n'
const int N = 1e5+5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
using namespace std;

inline int read() {
	int ans=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-'){f=-1;}ch=getchar();}
	while(ch>='0'&&ch<='9'){ans=(ans<<3)+(ans<<1)+(ch^48);ch=getchar();}
	return ans*f;
}
void write(int x) {
	if(x<0){putchar('-');x=-1;}
	if(x>9){write(x/10);}
	putchar(x%10|48);
}

void solve() {
	int n , pre , now ; 
	n = read() ; 
	cout << "? 1" << endl;
	pre = read() ; 
	int left = 1 , right = n ; 
	while(right >= left) {
		int mid = (right+left)>>1;
		cout << "? "<<mid<< endl ;
		now = read() ;
		if ( now == pre ) {
			cout << "! " << mid << endl ;
			break ; 
		}
		else if ( now > pre ) {
			left = mid + 1 ;
		}
		else {
			right = mid - 1 ;
		}
		pre = now ;
	}
}

signed main()
{
	int t = 1 ;
//	t = read() ;
	while(t -- ) {
		solve() ;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
3

output:

? 1
? 5
? 8
? 9
! 9

result:

ok Correct position at 9

Test #3:

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

input:

9
1
2
3
3

output:

? 1
? 5
? 7
? 8
! 8

result:

ok Correct position at 8

Test #4:

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

input:

8
1
2
3
3

output:

? 1
? 4
? 6
? 7
! 7

result:

ok Correct position at 7

Test #5:

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

input:

7
1
2
3
3

output:

? 1
? 4
? 6
? 7
! 7

result:

ok Correct position at 7

Test #6:

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

input:

6
1
2
3
3

output:

? 1
? 3
? 5
? 6
! 6

result:

ok Correct position at 6

Test #7:

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

input:

5
1
2
3
3

output:

? 1
? 3
? 4
? 5
! 5

result:

ok Correct position at 5

Test #8:

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

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 1
! 1

result:

wrong answer Wrong favorite light!