結果

問題 No.380 悪の台本
ユーザー rpy3cpprpy3cpp
提出日時 2016-06-18 00:39:58
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 100 ms / 1,000 ms
コード長 1,436 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 11,136 KB
実行使用メモリ 8,444 KB
最終ジャッジ日時 2023-08-06 19:47:27
合計ジャッジ時間 1,070 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,924 KB
testcase_01 AC 17 ms
7,844 KB
testcase_02 AC 17 ms
7,872 KB
testcase_03 AC 16 ms
7,816 KB
testcase_04 AC 20 ms
8,092 KB
testcase_05 AC 33 ms
8,188 KB
testcase_06 AC 27 ms
8,244 KB
testcase_07 AC 100 ms
8,128 KB
testcase_08 AC 30 ms
8,444 KB
testcase_09 AC 20 ms
8,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def solve(line):
    name = line[:5]
    if name == 'digi ':
        return ends_with(line[5:].lower(), 'nyo')
    elif name == 'petit':
        if len(line) < 6:
            return False
        return (line[5] == ' ') and ends_with(line[6:].lower(), 'nyu')
    elif name == 'rabi ':
        return solve_rabi(line[5:].lower())
    elif name == 'gema ':
        return ends_with(line[5:].lower(), 'gema')
    elif name == 'piyo ':
        return ends_with(line[5:].lower(), 'pyo')
    else:
        return False

def ends_with(line, txt):
    n = len(line)
    if n < len(txt):
        return False
    if line.endswith(txt):
        return True
    elif n >= 1 and is_symbol(line[-1]):
        if line[:-1].endswith(txt):
            return True
        elif n >= 2 and is_symbol(line[-2]):
            if line[:-2].endswith(txt):
                return True
            elif n >= 3 and is_symbol(line[-3]):
                if line[:-3].endswith(txt):
                    return True
    return False

def is_symbol(char):
    ordc = ord(char)
    if 48 <= ordc <= 57 or 65 <= ordc <= 90 or 97 <= ordc <= 122:
        return False
    return True

def solve_rabi(line):
    for c in line:
        if not is_symbol(c):
            return True
    return False

if __name__ == '__main__':
    for line in sys.stdin:
        if solve(line[:-1]):
            print('CORRECT (maybe)')
        else:
            print('WRONG!')
0