Submission #949183

# Submission time Handle Problem Language Result Execution time Memory
949183 2024-03-19T03:24:00 Z koukirocks Worm Worries (BOI18_worm) C++17
0 / 100
5 ms 500 KB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
 
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=2e5+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
 
int n,m,k,q;

int query(int x,int y,int z) {
	if (x>n or x<=0) return 0;
	if (y>m or y<=0) return 0;
	if (z>k or z<=0) return 0;
	cout<<"? "<<x<<" "<<y<<" "<<z<<"\n"<<flush;
	int ans;
	cin>>ans;
	if (ans==-1) exit(0);
	return ans;
}

int main() {
	speed;
	cin>>n>>m>>k>>q;
//	if (n==1000000) {
		mt19937 rnd(time(0)+3393848);
		uniform_int_distribution<int> pic(1,n);
		int maxx=0;
		int id=0;
		for (int i=0;i<n/10000;i++) {
			int now=pic(rnd);
//			cout<<now<<"\n";
			int rlt=query(now,1,1);
			if (rlt>maxx) {
				maxx=rlt;
				id=now;
			}
		}
		int dir=-1;
		if (query(id+1,1,1)>maxx) {
			dir=0;
		}
		if (query(id-1,1,1)>maxx) {
			dir=1;
		}
		if (dir==-1) {
			cout<<"! "<<id<<" 1 1\n";
			return 0;
		}
		int now=id+1;
		int val=query(now,1,1);
		int nxt=query(now+1,1,1);
		while (nxt>val) {
			val=nxt;
			now++;
			nxt=query(now+1,1,1);
		}
		cout<<"! "<<now<<" 1 1"<<"\n";
//	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Incorrect 1 ms 344 KB not a local maximum
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB too many queries. input: ? 881021 1 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB not a local maximum
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 0 ms 344 KB not a local maximum
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 500 KB not a local maximum
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB not a local maximum
3 Halted 0 ms 0 KB -