QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#799003 | #9804. Guess the Polygon | qlwpc | RE | 13ms | 11792kb | Python3 | 976b | 2024-12-04 20:18:14 | 2024-12-04 20:18:14 |
Judging History
answer
import fractions
import sys
def query(x : int):
print(f"? {x} 1")
sys.stdout.flush()
r, s = tuple(map(int, input().split()))
return fractions.Fraction(r, s)
T=int(input())
while T>0:
T-=1
n=int(input())
A = [tuple(map(int,input().split())) for _ in range(n)]
A.sort()
lstlen = fractions.Fraction(0, 1)
ans = fractions.Fraction(0, 1)
lstx = A[0][0]
ton = [0 for _ in range(1001)]
mx = 0
for x,y in A:
ton[x]+=1
mx = max(mx, x)
for i in range(n):
if i!=0 and A[i][0]==A[i-1][0]:
continue
x = A[i][0]
if x==mx and ton[x]==1:
ans = ans + lstlen*(x-lstx)*fractions.Fraction(1,2)
elif ton[x]>1 or i>0:
len = query(x)
ans = ans + (lstlen+len)*(x-lstx)*fractions.Fraction(1,2)
lstlen=len
lstx = x
print(f"! {ans.numerator} {ans.denominator}")
sys.stdout.flush()
詳細信息
Test #1:
score: 100
Accepted
time: 13ms
memory: 11792kb
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
Dangerous Syscalls
input:
9 4 1 1 1 3 3 0 0 0 3 1
output:
? 1 1 ! 9 2