TOPIC

30% W.A - Alguém..?

h10000 asked 5 years ago

def who_won(match):
    if match[0] > match[1]:
        return 1
    elif match[1] > match[0]:
        return 2
    else:
        return 0

def compute_points(winner):
    if winner == 1: 
        teams[1]['points'] += 3
    elif winner == 2: 
        teams[2]['points'] += 3
    else:
        teams[1]['points'] += 1
        teams[2]['points'] += 1

def read_data():
    return list(map(int, map(str.strip, input().split('x'))))

cases = int(input())

for i in range(cases):
    teams = {
                1: {'points': 0, 'sd': 0, 'outhome': 0}
                ,2: {'points': 0, 'sd': 0, 'outhome': 0}
            }
    match1 = read_data()
    match2 = read_data()

    teams[1]['sd'] = (match1[0] + match2[1]) - (match1[1] + match2[0])
    teams[2]['sd'] = (match1[1] + match2[0]) - (match1[0] + match2[1])

    teams[1]['outhome'] = match2[1]
    teams[2]['outhome'] = match1[1]

    match2.reverse()

    compute_points(who_won(match1))
    compute_points(who_won(match2))

    if teams[1]['points'] > teams[2]['points']:
        print('Time 1')
    elif teams[2]['points'] > teams[1]['points']:
        print('Time 2')
    else:
        if teams[1]['sd'] > teams[2]['sd']:
            print('Time 1')
        elif teams[2]['sd'] > teams[2]['sd']:
            print('Time 2')
        else:
            if teams[1]['outhome'] > teams[2]['outhome']:
                print('Time 1')
            elif teams[2]['outhome'] > teams[2]['outhome']:
                print('Time 2')
            else: 
                print('Penaltis')

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.