結果

問題 No.380 悪の台本
ユーザー rpy3cpprpy3cpp
提出日時 2016-06-17 23:45:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,322 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-24 14:22:20
合計ジャッジ時間 1,004 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 30 ms
10,624 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 116 ms
10,752 KB
testcase_08 AC 27 ms
11,008 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def solve(line):
    name = line[:5]
    if name == 'digi ':
        return ends_with(line[5:], 'nyo')
    elif name == 'petit':
        return ends_with(line[6:], 'nyu')
    elif name == 'rabi ':
        return solve_rabi(line[5:])
    elif name == 'gema ':
        return ends_with(line[5:], 'gema')
    elif name == 'piyo ':
        return ends_with(line[5:], '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 is_symbol(c):
            return True
    return False

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