이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> ipii;
vector <int> vx = {1, -1, 0, 0, 0, 0};
vector <int> vy = {0, 0, 1, -1, 0, 0};
vector <int> vz = {0, 0, 0, 0, 1, -1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int all, n, m, k, q;
int ansx, ansy, ansz;
int que(int a, int b, int c){
if(a<=0 || a>n || b<=0 || b>m || c<=0 || c>k) return -1;
cout << "? " << a << ' ' << b << ' ' << c << endl;
all++;
int x; cin >> x; return x;
}
int num(int r){
int x = rng(); x = abs(x);
x %= r; x++;
return x;
}
signed main(){
cin >> n >> m >> k >> q;
while(all < q){
int tot = 0;
int a = num(n), b = num(m), c = num(k);
// cout << a << ' ' << b << ' ' << c << "abc\n";
int sta = que(a, b, c), nw = sta;
while(tot < 20){
int num = -1, idx = -1, waduh = 0;
// cout << nw << " nw\n";
for(int i=0; i<2; i++){
if(all == q){
waduh = 1; break;
}
int ret = que(a+vx[i], b+vy[i], c+vz[i]);
if(ret == -1) continue;
if(nw <= ret){
idx = i; num = ret;
}
}
if(idx==-1 && !waduh){
ansx = a; ansy = b; ansz = c;
break;
} else {
a += vx[idx]; b += vy[idx]; c += vz[idx];
nw = num;
tot++;
}
}
}
cout << "! " << ansx << ' ' << ansy << ' '<< ansz << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |