이 제출은 이전 버전의 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 %= 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);
int sta = que(a, b, c);
while(tot < 20){
int mx = -1, idx = -1, done = 0;
for(int i=0; i<6; i++){
if(all == q) break;
int ret = que(a+vx[i], b+vy[i], c+vz[i]);
if(i==5) done = 1;
if(ret == -1) continue;
if(mx <= ret){
mx = ret;
idx = i;
}
}
if(mx==-1 && done){
ansx = a; ansy = b; ansz = c;
break;
} else {
a += vx[idx]; b += vy[idx]; c += vz[idx];
tot++;
}
}
}
cout << "! " << ansx << ' ' << ansy << ' '<< ansz << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
worm.cpp: In function 'int main()':
worm.cpp:38:7: warning: unused variable 'sta' [-Wunused-variable]
38 | int sta = que(a, b, c);
| ^~~
# | 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... |