結果

問題 No.380 悪の台本
ユーザー maspy
提出日時 2020-02-26 13:28:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 1,017 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-10-13 15:17:41
合計ジャッジ時間 1,427 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 4 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
query = readlines()


# %%
def end_with_word_plus_symbols(S, word):
    i = S.rfind(word)
    if i < 0 or i < len(S) - 3 - len(word):
        return False
    T = S[i + len(word):]
    return all(not x.isalnum() for x in T)


# %%
def is_ok(S, chara):
    S = S.lower()
    if chara == 'digi':
        return end_with_word_plus_symbols(S, 'nyo')
    if chara == 'petit':
        return end_with_word_plus_symbols(S, 'nyu')
    if chara == 'gema':
        return end_with_word_plus_symbols(S, 'gema')
    if chara == 'piyo':
        return end_with_word_plus_symbols(S, 'pyo')
    if chara == 'rabi':
        return not S.isalnum()
    return False


# %%
for line in query:
    S = line.decode().rstrip()
    words = S.split()
    chara = words[0]
    S = ''.join(words[1:])
    if is_ok(S, chara):
        print('CORRECT (maybe)')
    else:
        print('WRONG!')
0