QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#892193 | #9804. Guess the Polygon | ucup-team134# | RE | 19ms | 10880kb | Python3 | 866b | 2025-02-10 00:25:50 | 2025-02-10 00:25:51 |
Judging History
answer
from fractions import Fraction
import sys
import math
def qr(k):
print(f"? {k} 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.sort()
if pts[0][0] == pts[-1][0]:
print("! 0 1")
sys.stdout.flush()
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()
详细
Test #1:
score: 100
Accepted
time: 19ms
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