QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#639916 | #9227. Henry the Plumber | propane | WA | 22ms | 11960kb | Python3 | 1.6kb | 2024-10-13 23:52:19 | 2024-10-13 23:52:20 |
Judging History
answer
from fractions import Fraction
from math import gcd
def dot(a, b):
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
def minus(a, b):
return (a[0] - b[0], a[1] - b[1], a[2] - b[2])
def solve(a1, b1, c1, a2, b2, c2):
if a1 * b2 == a2 * b1: return None, None
if a1 == 0 or a2 == 0:
if a2 == 0:
a1, a2 = a2, a1
b1, b2 = b2, b1
c1, c2 = c2, c1
y = Fraction(c1 / b)
x = Fraction(c2 - b2 * y, x2)
return (x, y)
lcm = abs(a1 * a2) // abs(gcd(a1, a2))
t1 = lcm // a1
t2 = lcm // a2
k1 = b2 * t2 - b1 * t1
k2 = c2 * t2 - c1 * t1
y = Fraction(k2, k1)
x = Fraction(c1 - b1 * y, a1)
return (x, y)
for _ in range(int(input())):
try:
x1, y1, z1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3, z3 = map(int, input().split())
x4, y4 = map(int, input().split())
p1 = (x1, y1, z1)
p2 = (x2, y2, 0)
p3 = (x3, y3, z3)
p4 = (x4, y4, 0)
if (dot(minus(p3, p1), p2) == 0 and dot(minus(p3, p1), p4) == 0):
print(2)
continue
x, y = solve(x2, y2, x1 * x2 + y1 * y2, x4, y4, x3 * x4 + y3 * y4)
if x is None and y is None:
print(4)
continue
a = 1
b = -(z1 + z3)
c = z1 * z3 + (x - x1) * (x - x3) + (y - y1) * (y - y3)
if b * b - 4 * a * c >= 0:
print(3)
else:
print(4)
except:
print(x1, y1, z1)
print(x2, y2)
print(x3, y3, z3)
print(x4, y4)
exit(0)
詳細信息
Test #1:
score: 100
Accepted
time: 22ms
memory: 11780kb
input:
2 -1 -1 3 1 1 2 2 3 2 2 5 5 1 3 0 7 6 -2 1 -2
output:
4 3
result:
ok 2 number(s): "4 3"
Test #2:
score: -100
Wrong Answer
time: 13ms
memory: 11960kb
input:
100 -13 -5 -7 -19 19 -19 -13 0 -7 15 -20 20 19 -17 18 20 -20 -1 18 -19 -18 15 -14 -19 18 19 -20 6 20 -19 -12 9 1 7 -16 -13 -14 -8 8 -13 -19 16 9 20 -19 19 -18 -11 19 -18 19 20 -8 12 20 -11 -9 18 -19 -18 8 11 -13 12 -18 18 13 8 4 -18 -16 20 17 -19 18 20 -18 -3 20 -19 -17 -20 -5 -18 -19 19 16 15 19 20...
output:
4 4 4 4 4 4 3 4 4 4 3 4 4 3 3 4 3 4 4 4 4 4 4 4 4 4 4 4 4 3 3 4 4 4 4 4 4 4 4 4 -18 5 -3 0 17 20 13 5 -11 -13
result:
wrong answer 29th numbers differ - expected: '3', found: '4'