QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#378470#6394. Turn on the LightAprilend#TL 0ms0kbC++141.5kb2024-04-06 13:07:112024-04-06 13:07:12

Judging History

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

  • [2024-04-06 13:07:12]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-06 13:07:11]
  • 提交

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;
}
int pre, now, l, r;
int ck(int mid) {
	int t; 
	cout<<"? "<<mid;
	cin>>pre;
	cout<<"? "<<l;
	cin>>now;
	if(now>pre) re 1;
	else if(now==pre) re 2;
	else if(now<pre) re 3;


}
void Solve(void)
{
	int n; cin>>n;
	l=1, r=n;

	while(l <= r) {
        ll mid = l + r >> 1;
		int t=ck(mid);
        if(t==1) l=mid+1;
		else if(t==2) {
			cout<<"! "<<l<<edl;
			re;
		}
        else r=mid-1;
    }
	cout.flush();
}
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: 0
Time Limit Exceeded

input:

3

output:

? 2

result: