QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#866276 | #9804. Guess the Polygon | Nana7 | RE | 0ms | 0kb | Python3 | 1.5kb | 2025-01-22 14:07:37 | 2025-01-22 14:07:39 |
Judging History
answer
from fractions import Fraction
from functools import cmp_to_key
import sys
class point :
def __init__(self,x,y):
self.x=x
self.y=y
def cmp(a,b) :
if a.x>b.x : return 1
else : return -1
def query(pos,x) :
print("? ", end='')
print(pos, end=' ')
print(x)
sys.stdout.flush()
s=input()
num=s.strip().split(' ')
f=Fraction(int(num[0]),int(num[1]))
return f
def solve() :
n=int(input())
p,p1=[],[]
for i in range(n) :
s=input()
num=s.strip().split(' ')
p.append(point(int(num[0]),int(num[1])))
p.sort(key=cmp_to_key(cmp))
p.append(point(1e5,1e5))
for i in range(0,len(p)-1) :
if p[i].x != p[i+1].x : p1.append(p[i])
rn = len(p1)
if rn == n :
ans = Fraction(0,1)
frc = []
frc.append(Fraction(0,1))
for i in range(1,rn-1) :
area = query(p1[i].x,1)
frc.append(area)
frc.append(Fraction(0,1))
for i in range(0,rn-1) :
ans = ans + (p1[i+1].x-p1[i].x) * ( frc[i] + frc[i+1] )
ans = ans * Fraction(1,2)
print(ans.numerator,ans.denominator)
else :
ans = Fraction(0,1)
for i in range(0,rn-1) :
area = query(p1[i].x+p1[i+1].x,2)
ans = ans + area * (p1[i+1].x-p1[i].x)
#ans = ans * Fraction(1,2)
print(ans.numerator,ans.denominator)
if __name__ == "__main__" :
T=int(input())
for i in range(T) :
solve()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
2 4 3 0 1 3 1 1 0 0 1 1 1 1
output:
? 1 2 ? 4 2 3 1