QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#892193#9804. Guess the Polygonucup-team134#RE 19ms10880kbPython3866b2025-02-10 00:25:502025-02-10 00:25:51

Judging History

This is the latest submission verdict.

  • [2025-02-10 00:25:51]
  • Judged
  • Verdict: RE
  • Time: 19ms
  • Memory: 10880kb
  • [2025-02-10 00:25:50]
  • Submitted

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()
		
	

Details

Tip: Click on the bar to expand more detailed information

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

result: