結果
| 問題 |
No.263 Common Palindromes Extra
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-07 18:32:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,165 bytes |
| コンパイル時間 | 505 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 67,840 KB |
| 最終ジャッジ日時 | 2024-11-30 13:29:50 |
| 合計ジャッジ時間 | 2,402 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 12 |
ソースコード
class TrieNode:
def __init__(self):
self.children = {}
self.is_terminal = False
def insert_into_trie(root, binary_string):
current_node = root
for char in binary_string:
if char not in current_node.children:
current_node.children[char] = TrieNode()
current_node = current_node.children[char]
current_node.is_terminal = True
def count_free_positions(root, current_depth, L):
if current_depth > L:
return 0
if root.is_terminal:
# このノードが終端なら、その子は考慮しない
return 0
count = 1 # このノード自体が新しい文字列の候補
for child in root.children.values():
count += count_free_positions(child, current_depth + 1, L)
return count
def solve(N, L, strings):
root = TrieNode()
for s in strings:
insert_into_trie(root, s)
free_positions = count_free_positions(root, 0, L)
if free_positions % 2 == 1:
return "Alice"
else:
return "Bob"
# Example usage
N = int(input())
L = int(input())
strings = [input().strip() for _ in range(N)]
print(solve(N, L, strings))