QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#795116#9804. Guess the Polygonucup-team2112#RE 13ms11828kbPython3801b2024-11-30 17:59:342024-11-30 17:59:39

Judging History

This is the latest submission verdict.

  • [2024-11-30 17:59:39]
  • Judged
  • Verdict: RE
  • Time: 13ms
  • Memory: 11828kb
  • [2024-11-30 17:59:34]
  • Submitted

answer

from fractions import Fraction
import sys

T = int(input())

while T > 0:
    T -= 1
    n = int(input())
    point = []
    for i in range(n):
        x, y = map(int, input().split())
        point.append([x, y])
    point.sort(key=lambda item: item[0])
    pre = Fraction(0)
    pre_x = point[0][0]
    res = Fraction(0)
    for i in range(1, n):
        x, y = point[i]
        if x == pre_x:
            continue
        if i != n - 1:
            print(f"? {x} {1}")
            sys.stdout.flush()
            p, q = map(int, input().split())
        else:
            p, q = 0, 1
        res += (Fraction(p, q) + pre) * (x - pre_x)
        pre_x = x
        pre = Fraction(p, q)
    res /= 2
    print(f"! {res.numerator} {res.denominator}")
    sys.stdout.flush()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 11828kb

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

result: