이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
vi d6[6] = {{1,0,0},{-1,0,0},{0,1,0},{0,-1,0},{0,0,1},{0,0,-1}};
int qry (int x, int y, int z) {
cout << "? " << x << " " << y << " " << z << endl;
int res; cin >> res;
return res;
}
int rand (int a, int b) {
return a + rand() % (b-a+1);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
srand(128);
int n, m, k, q; cin >> n >> m >> k >> q;
if (n>1 && m>1) {
int best = 0, a = 0, b = 0, c = 0;
rep (i,1,q/2) {
int x = rand(1,n), y = rand(1,m), z = rand(1,k);
int res = qry (x, y, z);
if (res>best) {
best = res;
a = x, b = y, c = z;
}
}
while (true) {
bool hap = 0;
rep (i,0,5) {
int na = a + d6[i][0];
int nb = b + d6[i][1];
int nc = c + d6[i][2];
int res = qry (na, nb, nc);
if (res > best) {
best = res;
hap = 1;
a = na;
b = nb;
c = nc;
break;
}
}
if (!hap) {
cout << "! " << a << " "<< b << " " << c << endl;
break;
}
}
}
return 0;
}
# | 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... |