Submission #749948

# Submission time Handle Problem Language Result Execution time Memory
749948 2023-05-29T02:05:09 Z vjudge1 Carnival (CEOI14_carnival) C++17
0 / 100
0 ms 208 KB
#include<bits/stdc++.h>
using namespace std;
int ask(int l, int r) {
	if(l>=r) return -1;
	cout<<"? "<<l<<" "<<r<<endl;
	int x;
	cin>>x;
	return x;
}
signed main() {
//	ios_base::sync_with_stdio(0);
//	cin.tie(0);
	int n;
	cin>>n;
	int smax=ask(1,n);
	int l,r;
	if(smax==n||ask(1,smax)==smax) {
		l=1; r=smax;
		while(l<r-1) {
			int m=(l+r)/2;
			if(ask(m,smax)==smax) {
				l=m;
			}
			else r=m;
		}
		cout<<"! "<<l<<endl;
	}
	else {
		l=smax, r=n;
		while(l<r-1) {
			int m=(l+r)/2;
			if(ask(smax,m)==smax) {
				r=m;
			}
			else l=m;
		}
		cout<<"! "<<r<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -