結果

問題 No.380 悪の台本
ユーザー rpy3cpprpy3cpp
提出日時 2016-06-18 00:36:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,520 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 11,084 KB
実行使用メモリ 8,520 KB
最終ジャッジ日時 2023-08-06 19:47:24
合計ジャッジ時間 1,325 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,868 KB
testcase_01 AC 16 ms
7,912 KB
testcase_02 AC 15 ms
7,988 KB
testcase_03 AC 16 ms
7,788 KB
testcase_04 AC 19 ms
8,044 KB
testcase_05 AC 32 ms
8,012 KB
testcase_06 AC 27 ms
8,060 KB
testcase_07 AC 103 ms
8,224 KB
testcase_08 AC 30 ms
8,520 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def solve(line):
    name = line[:5]
    if name == 'digi ':
        return ends_with(line[5:].lower(), 'nyo')
    elif name == 'petit':
        return 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]):  # rstrip() では、末尾の改行だけでなく、空白文字も削ってしまう。[:-1]として、末尾の改行のみを削るようにした。
            print('CORRECT (maybe)')
        else:
            print('WRONG!')
0