結果
| 問題 | No.11 カードマッチ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-20 12:34:09 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 5,000 ms |
| コード長 | 928 bytes |
| 記録 | |
| コンパイル時間 | 339 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 15,488 KB |
| 最終ジャッジ日時 | 2026-04-20 12:34:17 |
| 合計ジャッジ時間 | 3,137 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
def count_matching_cards(total_mark_types, total_number_types, hand_cards):
hand_marks = set()
hand_numbers = set()
for mark, number in hand_cards:
hand_marks.add(mark)
hand_numbers.add(number)
mark_match = len(hand_marks) * total_number_types
number_match = len(hand_numbers) * total_mark_types
double_count = len(hand_marks) * len(hand_numbers)
return mark_match + number_match - double_count - len(hand_cards)
def read_hand_cards(hand_size):
return [tuple(map(int, input().split())) for _ in range(hand_size)]
def main():
total_mark_types = int(input())
total_number_types = int(input())
hand_size = int(input())
hand_cards = read_hand_cards(hand_size)
matching_card_count = count_matching_cards(
total_mark_types,
total_number_types,
hand_cards
)
print(matching_card_count)
if __name__ == "__main__":
main()