QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#308145 | #6568. Space Alignment | Mizara# | WA | 10ms | 9928kb | Python3 | 613b | 2024-01-19 16:42:53 | 2024-01-19 16:42:54 |
Judging History
answer
def f():
n = int(input())
res = -1
q = []
for i in range(n):
line = input()
a, b = 0, 0
for x in line[:-1]:
if x == 's':
a += 1
else:
b += 1
if line[-1] == '{':
q.append((a, b))
continue
x, y = q.pop()
if x < a:
x, a = a, x
y, b = b, y
if y > b:
print(-1)
return
a = x - a
b = b - y
if a == 0 and b == 0:
continue
if b == 0:
print(-1)
return
if a % b:
print(-1)
return
a //= b
if res >= 0 and res != a:
print(-1)
return
res = a
print(max(res, 0))
if __name__ == '__main__':
f()
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 9912kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 9928kb
input:
2 { }
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'