QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#308145#6568. Space AlignmentMizara#WA 10ms9928kbPython3613b2024-01-19 16:42:532024-01-19 16:42:54

Judging History

你现在查看的是最新测评结果

  • [2024-01-19 16:42:54]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:9928kb
  • [2024-01-19 16:42:53]
  • 提交

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'