1 / 5
Jan 2022

Hello. I have WA, although tests in examples are OK. My code here:
tests = int(input())

for test in range(tests):
    n = int(input())
    accounts = set()
    for x in range(n):
        a = tuple([str(x) for x in input().split()])
        accounts.add(a)
    if test != tests - 1:
        empty_line = input()
    accounts = list(accounts)
    accounts.sort(key=lambda y: (y[0], y[1], y[2], y[3], y[4], y[5]))

    owners = {}
    if test == 0:
        print()

    for x in accounts:
        owner = x[2]+x[3]+x[4]+x[5]
        if owner not in owners:
            owners[owner] = 1
        else:
            owners[owner] += 1
        print(x[0], x[1], x[2], x[3], x[4], x[5], owners[owner])

Why do you print a line before the first test case, rather than between test cases?

Maybe it doesn’t need. I have WA and without this condition.

I see you’ve not got AC - what was the problem?

I’ve rewritten this task, using Counter (from collections).