結果

問題 No.380 悪の台本
ユーザー maspy
提出日時 2020-02-26 13:34:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 1,085 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-10-13 15:17:52
合計ジャッジ時間 916 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 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):
    if S[0] == ' ':
        return False
    words = S.split()
    if not words:
        return False
    chara = words[0]
    S = ''.join(words[1:]).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 any(x.isalnum() for x in S)
    return False


# %%
for line in query:
    S = line.decode().rstrip()
    if is_ok(S):
        print('CORRECT (maybe)')
    else:
        print('WRONG!')
0