結果

問題 No.2784 繰り上がりなし十進和
ユーザー NP
提出日時 2024-06-14 22:31:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-14 22:31:56
合計ジャッジ時間 3,159 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def bfs_digits(init_digits):
    seen = set(init_digits)
    queue = deque(init_digits)
    
    while queue:
        cur = queue.popleft()
        for d in seen.copy():  
            new_digit = (cur + d) % 10
            if new_digit not in seen:
                seen.add(new_digit)
                queue.append(new_digit)
                if len(seen) == 10:
                    return seen
    return seen
original_nums = [input().strip() for _ in range(6)]
digit_pos = [[int(num[i]) for num in original_nums] for i in range(6)]
result = 1

for digits in digit_pos:
    unique_digits = bfs_digits(digits)
    result *= len(unique_digits)

print(result)
0