結果
| 問題 |
No.3108 Luke or Bishop
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-18 20:59:22 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,155 bytes |
| コンパイル時間 | 179 ms |
| コンパイル使用メモリ | 12,160 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2025-04-18 20:59:24 |
| 合計ジャッジ時間 | 1,916 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 15 |
ソースコード
def word_to_number(words):
singles = {
"zero": 0, "one": 1, "two": 2, "three": 3,
"four": 4, "five": 5, "six": 6, "seven": 7,
"eight": 8, "nine": 9
}
teens = {
"ten": 10, "eleven": 11, "twelve": 12, "thirteen": 13,
"fourteen": 14, "fifteen": 15, "sixteen": 16,
"seventeen": 17, "eighteen": 18, "nineteen": 19
}
tens = {
"twenty": 20, "thirty": 30, "forty": 40,
"fifty": 50, "sixty": 60, "seventy": 70,
"eighty": 80, "ninety": 90
}
words = words.strip().lower().split()
result = 0
i = 0
while i < len(words):
if words[i] in teens:
result += teens[words[i]]
i += 1
elif words[i] in tens:
result += tens[words[i]]
if i + 1 < len(words) and words[i + 1] in singles:
result += singles[words[i + 1]]
i += 2
else:
i += 1
elif words[i] in singles:
result += singles[words[i]]
i += 1
else:
i += 1
return result
def chess_moves(x, y):
if x == 0 and y == 0:
return 0
rook = 1 if x == 0 or y == 0 else 2
if (x + y) % 2 != 0:
bishop = float('inf')
elif x == y or x == -y:
bishop = 1
else:
bishop = 2
return min(rook, bishop)
# ---- Input Handler ----
import sys
input_line = sys.stdin.read().strip().lower()
tokens = input_line.split()
if all(token.isdigit() for token in tokens):
# Numeric input
x, y = map(int, tokens)
else:
# Word input
# Strategy: split the input into two word groups (first for x, second for y)
# e.g., "twenty one five" → ["twenty one", "five"]
# e.g., "forty four" → ["forty", "four"]
found = False
for i in range(1, len(tokens)):
x_words = " ".join(tokens[:i])
y_words = " ".join(tokens[i:])
x = word_to_number(x_words)
y = word_to_number(y_words)
if isinstance(x, int) and isinstance(y, int):
found = True
break
if not found:
x = y = 0 # fallback
print(chess_moves(x, y))