Submission #895994

# Submission time Handle Problem Language Result Execution time Memory
895994 2023-12-31T11:41:17 Z pcc Worm Worries (BOI18_worm) C++14
0 / 100
2 ms 4192 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>


const int mxn = 1e6+10;
int N,M,K;
int dp[mxn];

int ask(int x,int y = 1,int z = 1){
	if(dp[x] != -1)return dp[x];
	cout<<"? "<<x<<' '<<y<<' '<<z<<endl;
	int re;
	cin>>re;
	if(re == -1)exit(0);
	dp[x] = re;
	return re;
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>N>>M>>K;
	int l = 1,r = N;
	while(r-l>1){
		int mid = (l+r)>>1;
		if(ask(mid)>=ask(mid+1))r = mid;
		else l = mid+1;
	}
	if(l == r)cout<<"! "<<l<<" 1 1"<<endl;
	else if(ask(l)>ask(r))cout<<"! "<<l<<" 1 1"<<endl;
	else cout<<"! "<<r<<" 1 1"<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4184 KB Output is correct
2 Correct 1 ms 4192 KB Output is correct
3 Incorrect 1 ms 4184 KB not a local maximum
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4184 KB too many queries. input: ? 985999 1 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4184 KB Output is correct
2 Incorrect 1 ms 4184 KB not a local maximum
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4184 KB Output is correct
2 Correct 2 ms 4184 KB Output is correct
3 Correct 1 ms 4184 KB Output is correct
4 Incorrect 1 ms 4184 KB not a local maximum
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4184 KB Output is correct
2 Incorrect 1 ms 4184 KB not a local maximum
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4184 KB Output is correct
2 Incorrect 1 ms 4184 KB not a local maximum
3 Halted 0 ms 0 KB -