結果

問題 No.11 カードマッチ
ユーザー human_cipherhuman_cipher
提出日時 2021-06-20 22:58:53
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 329 ms / 5,000 ms
コード長 780 bytes
コンパイル時間 826 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 25,088 KB
最終ジャッジ日時 2023-09-05 01:44:10
合計ジャッジ時間 4,195 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,908 KB
testcase_01 AC 16 ms
7,888 KB
testcase_02 AC 16 ms
7,872 KB
testcase_03 AC 16 ms
7,864 KB
testcase_04 AC 148 ms
15,304 KB
testcase_05 AC 15 ms
7,832 KB
testcase_06 AC 307 ms
24,180 KB
testcase_07 AC 131 ms
14,912 KB
testcase_08 AC 185 ms
17,568 KB
testcase_09 AC 329 ms
25,088 KB
testcase_10 AC 261 ms
21,180 KB
testcase_11 AC 235 ms
19,928 KB
testcase_12 AC 255 ms
21,196 KB
testcase_13 AC 237 ms
20,236 KB
testcase_14 AC 139 ms
15,284 KB
testcase_15 AC 30 ms
9,280 KB
testcase_16 AC 40 ms
10,008 KB
testcase_17 AC 41 ms
10,056 KB
testcase_18 AC 40 ms
10,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

w = int(input())
h = int(input())
n = int(input())
SK = set([tuple(map(int,input().split())) for _ in range(n)])

Mark = [0 for _ in range(w+1)]
Num = [0 for _ in range(h+1)]

for s,k in SK:
    Mark[s] += 1
    Num[k] += 1

ans = 0
for i in range(w+1):
    if Mark[i] > 0:
        ans += (h-Mark[i])
for i in range(h+1):
    if Num[i] > 0:
        ans += (w-Num[i])

col = 0
Counted = set()
for s0,k0 in SK:
    for s1,k1 in SK:
        if s0 != s1 and k0 != k1:
            if (s0,k1) not in SK:
                if (s0,k1) not in Counted:
                    col += 1
                    Counted.add((s0,k1))
            if (s1,k0) not in SK:
                if (s1,k0) not in Counted:
                    col += 1
                    Counted.add((s1,k0))
ans -= col
print(ans)
0