Submission #749943

# Submission time Handle Problem Language Result Execution time Memory
749943 2023-05-29T02:03:09 Z vjudge1 Carnival (CEOI14_carnival) Java 11
Compilation error
0 ms 0 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;
	}
}

Compilation message

carnival.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
carnival.java:1: error: class, interface, or enum expected
#include<bits/stdc++.h>
        ^
carnival.java:3: error: class, interface, or enum expected
int ask(int l, int r) {
^
carnival.java:5: error: class, interface, or enum expected
	cout<<"? "<<l<<" "<<r<<endl;
	^
carnival.java:6: error: class, interface, or enum expected
	int x;
	^
carnival.java:7: error: class, interface, or enum expected
	cin>>x;
	^
carnival.java:8: error: class, interface, or enum expected
	return x;
	^
carnival.java:9: error: class, interface, or enum expected
}
^
carnival.java:14: error: class, interface, or enum expected
	cin>>n;
	^
carnival.java:15: error: class, interface, or enum expected
	int smax=ask(1,n);
	^
carnival.java:16: error: class, interface, or enum expected
	int l,r;
	^
carnival.java:17: error: class, interface, or enum expected
	if(smax==n||ask(1,smax)==smax) {
	^
carnival.java:18: error: class, interface, or enum expected
		l=1; r=smax;
		     ^
carnival.java:19: error: class, interface, or enum expected
		while(l<r-1) {
		^
carnival.java:21: error: class, interface, or enum expected
			if(ask(m,smax)==smax) {
			^
carnival.java:23: error: class, interface, or enum expected
			}
			^
carnival.java:25: error: class, interface, or enum expected
		}
		^
carnival.java:27: error: class, interface, or enum expected
	}
	^
carnival.java:30: error: class, interface, or enum expected
		while(l<r-1) {
		^
carnival.java:32: error: class, interface, or enum expected
			if(ask(smax,m)==smax) {
			^
carnival.java:34: error: class, interface, or enum expected
			}
			^
carnival.java:36: error: class, interface, or enum expected
		}
		^
carnival.java:38: error: class, interface, or enum expected
	}
	^
23 errors