結果

問題 No.380 悪の台本
ユーザー maspymaspy
提出日時 2020-02-26 13:37:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 213 ms / 1,000 ms
コード長 1,050 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-21 16:21:53
合計ジャッジ時間 1,417 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,496 KB
testcase_01 AC 28 ms
10,368 KB
testcase_02 AC 26 ms
10,496 KB
testcase_03 AC 28 ms
10,496 KB
testcase_04 AC 32 ms
10,752 KB
testcase_05 AC 48 ms
11,008 KB
testcase_06 AC 46 ms
11,008 KB
testcase_07 AC 213 ms
11,520 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 AC 35 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

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):
    words = S.split()
    message = ''.join(words[1:]).lower()
    if S.startswith('digi '):
        return end_with_word_plus_symbols(message, 'nyo')
    if S.startswith('petit '):
        return end_with_word_plus_symbols(message, 'nyu')
    if S.startswith('gema '):
        return end_with_word_plus_symbols(message, 'gema')
    if S.startswith('piyo '):
        return end_with_word_plus_symbols(message, 'pyo')
    if S.startswith('rabi '):
        return any(x.isalnum() for x in message)
    return False


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