結果
| 問題 | No.11 カードマッチ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-20 11:10:22 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 104 ms / 5,000 ms |
| コード長 | 655 bytes |
| 記録 | |
| コンパイル時間 | 708 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 15,484 KB |
| 最終ジャッジ日時 | 2026-04-20 11:10:40 |
| 合計ジャッジ時間 | 3,460 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
def count_matching_cards(W, H, 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) * H
number_match = len(hand_numbers) * W
double_count = len(hand_marks) * len(hand_numbers)
return mark_match + number_match - double_count - len(hand_cards)
def main():
W = int(input())
H = int(input())
N = int(input())
hand_cards = [tuple(map(int, input().split())) for _ in range(N)]
result = count_matching_cards(W, H, hand_cards)
print(result)
if __name__ == "__main__":
main()