QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#218024#6394. Turn on the LightCRN2010WA 0ms3376kbC++201.2kb2023-10-17 17:26:542023-10-17 17:26:54

Judging History

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

  • [2023-10-17 17:26:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3376kb
  • [2023-10-17 17:26:54]
  • 提交

answer

#include <bits/stdc++.h>
#define int 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 = -1 , now ; 
	n = read() ; 
	int left = 1 , right = n ; 
	while(right >= left) {
		int mid = (right+left)>>1;
		cout << "? "<<mid<< endl ;
		now = read() ;
		if ( pre == -1 ) {
			pre = now ;
			continue ;
		}
		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;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3376kb

input:

3
1
1

output:

? 2
? 2
! 2

result:

wrong answer Wrong favorite light!