QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#251946#6394. Turn on the Lightucup-team1074WA 1ms3628kbC++201.2kb2023-11-15 13:35:392023-11-15 13:35:40

Judging History

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

  • [2023-11-15 13:35:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3628kb
  • [2023-11-15 13:35:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
//#define endl '\n'
const LL maxn = 4e05+7;
const LL N=1e05+10;
const LL mod=1e09+7;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >t;
priority_queue<LL> q;
LL gcd(LL a, LL b){
	return b > 0 ? gcd(b , a % b) : a;
}

LL lcm(LL a , LL b){
	return a / gcd(a , b) * b;
}
int n , m;
int a[N];
void init(int n){
	for(int i = 0 ; i <= n ; i ++){
		a[i] = 0;
	}
}
void solve() 
{
	int n;
	cin >> n;
	int l = 1 , r = n;
	int vis[n + 5];
	int x = 0, prex = 0;
	while(l < r){
		if(x == 0){
			cout<<"? " << l <<endl;
			cin >> x;
			if(x == 0){
				cout<<"! " <<l<<endl;
				return;
			}
			else{
				l ++;
				prex = x;
			}
		}
		int mid = (l + r) / 2;
		cout<<"? "<<mid<<endl;
		cin >> x;
		if(x > prex){
			l = mid + 1;
		}
		else if(x < prex){
			r = mid - 1;
		}
		else{
			cout <<"! " << mid<<endl;
			return;
		}
	}
	cout<<"! "<<l<<endl;
}            
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
//	cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2

output:

? 1
? 2
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
0
1
0

output:

? 1
? 6
? 2
? 4
! 3

result:

ok Correct position at 3

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3552kb

input:

9
1
2
3
3

output:

? 1
? 5
? 7
? 8
! 9

result:

wrong answer Wrong favorite light!