結果
問題 |
No.380 悪の台本
|
ユーザー |
|
提出日時 | 2016-06-18 00:25:10 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 119 ms / 1,000 ms |
コード長 | 1,684 bytes |
コンパイル時間 | 127 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-06 22:51:08 |
合計ジャッジ時間 | 1,231 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 |
ソースコード
import sys def solve(line): if len(line) < 5: return False name = line[:5] if name == 'digi ': return ends_with(line[5:].lower(), 'nyo') elif name == 'petit': if len(line) < 9: return False return (line[5] == ' ') and 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.rstrip()): # コンテスト中の提出回答では、ここを line.strip() として、先頭の空白文字も削除してしまっていた。rstrip() なら、行末の空白文字のみを削除する。 print('CORRECT (maybe)') else: print('WRONG!')