ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1542. Автодополнение

WA#2 don't know what's the problem. HELP!
Послано ZHENG WANG 27 дек 2018 08:43
Can someone help me? Please?
I do it with Python3 ,and does not print out empty line after last queue
here's my code:

def getSecond(temp):
                return temp[1]

if __name__ == '__main__':
    while True:
        try:

            N = int(input())
            Words = []
            for n in range(N):
                Words.append(input().split())
                Words[n][1] = int(Words[n][1])

            M = int(input())
            Beginners = []
            for m in range(M):
                Beginners.append(input())

            for mm in range(M):
                start = list(Beginners[mm])
                matchs = []
                for nn in range(N):
                    word = list(Words[nn][0])
                    flag = True
                    for s in range(len(start)):
                        if start[s] != word[s]:
                            flag = False
                            break
                    if(flag):
                        matchs.append(Words[nn])
                if matchs != []:
                    matchs.sort()
                    matchs.sort(key = getSecond, reverse = True)
                    count = 0
                    for match in matchs:
                        if count > 10:
                            break
                        print(match[0])
                        count += 1

                if mm != M-1:
                    print()


        except:
            break


Re: WA#2 don't know what's the problem. HELP!
Послано zksumon 5 дек 2019 08:20
if no word found with any query dont print any new line