QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#822202 | #9804. Guess the Polygon | ucup-team3548 | RE | 0ms | 0kb | Python3 | 1.5kb | 2024-12-20 00:05:23 | 2024-12-20 00:05:23 |
Judging History
answer
from math import gcd
import sys
def Simp(A):
GCD=gcd(A[0],A[1])
Res=[A[0]//GCD,A[1]//GCD]
return Res
def Add(A,B):
X=A[0]*B[1]+A[1]*B[0]
Y=A[1]*B[1]
return Simp([X,Y])
def Minus(A,B):
X=A[0]*B[1]-A[1]*B[0]
Y=A[1]*B[1]
return Simp([X,Y])
def Times(A,B):
return Simp([A[0]*B[0],A[1]*B[1]])
def Divi(A,B):
return Simp([A[0]*B[1],A[1]*B[0]])
def First(A):
return A[0]
def Solve():
N=int(input())
XCor=[]
for i in range(N):
A,B=input().split()
XCor.append([int(A),1])
XCor.sort(key=First)
Last=XCor[0][0]
Tag=False
Ans=[0,1]
ToEnd=[0,1]
for i in range(1,N-1):
if XCor[i][0]==Last:
Tag=True
continue
Get=Simp([XCor[i][0]+Last,2])
print('!',Get[0],Get[1])
sys.stdout.flush()
X,Y=input().split()
X=int(X)
Y=int(Y)
Ans=Add(Ans,Times([X,Y],[XCor[i][0]-Last,1]))
ToEnd=Minus(Times([X,Y],[2,1]),ToEnd)
Last=XCor[i][0]
if Tag:
if XCor[N-1][0]!=Last:
Get=Simp([XCor[N-1][0]+Last,2])
print('!',Get[0],Get[1])
sys.stdout.flush()
X,Y=input().split()
X=int(X)
Y=int(Y)
Ans=Add(Ans,Times([X,Y],[XCor[N-1][0]-Last,1]))
else:
if XCor[N-1][0]!=Last:
Ans=Add(Ans,Times(ToEnd,[XCor[N-1][0]-Last,2]))
print('!',Ans[0],Ans[1]);
sys.stdout.flush()
T=int(input())
while T:
Solve()
T-=1
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
2 4 3 0 1 3 1 1 0 0
output:
! 1 2