QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#892187 | #9804. Guess the Polygon | ucup-team134# | RE | 17ms | 10880kb | Python3 | 830b | 2025-02-09 23:57:43 | 2025-02-09 23:57:43 |
Judging History
answer
from fractions import Fraction
import sys
def qr(x):
print(f"? {x} 1")
sys.stdout.flush()
x,y=map(int,input().split())
return Fraction(x,y)
def trap(a,b,d):
return d*(a+b)/2
t = int(input())
for k in range(t):
n=int(input())
pts=[]
for i in range(n):
x,y=map(int,input().split())
pts.append((x,y))
pts=sorted(pts)
if pts[0][0] == pts[-1][0]:
print(0)
continue
lst=Fraction(0,1)
if pts[0][0] != pts[1][0]:
lst=Fraction(0,1)
else:
lst=qr(pts[0][0])
area=Fraction(0,1)
for i in range(0,n-2):
if pts[i][0] != pts[i+1][0]:
d=pts[i+1][0]-pts[i][0]
novi=qr(pts[i+1][0])
area=area+trap(lst,novi,d)
lst=novi
if pts[n-2][0] != pts[n-1][0]:
area=area+trap(lst,0,pts[n-1][0]-pts[n-2][0])
print(f"! {area.numerator} {area.denominator}")
sys.stdout.flush()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 17ms
memory: 10880kb
input:
2 4 3 0 1 3 1 1 0 0 2 1 3 0 0 999 1000 1000 999 1999 1000
output:
? 1 1 ! 3 1 ? 999 1 ! 1999 2
result:
ok correct! (2 test cases)
Test #2:
score: -100
Runtime Error
input:
9 4 1 1 1 3 3 0 0 0 3 1
output:
? 1 1 ! 9 2