이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
from random import randint
n, m, k, q = [int(i) for i in input().split()]
cache = {}
def ask(t):
x, y, z = t
if x < 1 or x > n or y < 1 or y > m or z < 1 or z > k:
return -1
if (x, y, z) in cache:
return cache[(x, y, z)]
print(f"? {x} {y} {z}")
ans = int(input())
cache[(x, y, z)] = ans
return ans
def answer(t):
x, y, z = t
print(f"! {x} {y} {z}")
exit(0);
def biggest_neighbor(x, y, z):
ans = (x, y, z)
r = ask(ans)
neis = [(x+1,y,z),(x-1,y,z),(x,y+1,z),(x,y-1,z),(x,y,z+1),(x,y,z-1)]
for nei in neis:
r2 = ask(nei)
if r2 > r:
r = r2
ans = nei
return ans
def get_rand():
return (randint(1,n), randint(1,m), randint(1,k))
R = q//3
W = q-R
start = None
score = 0
for i in range(R):
test = get_rand()
ts = ask(test)
if ts > score:
start = test
score = ts
for i in range(W):
b = biggest_neighbor(start)
if b == start:
answer(b)
start = b
# | 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... |