結果

問題 No.11 カードマッチ
ユーザー htensaihtensai
提出日時 2019-12-30 17:15:39
言語 Java19
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 2,205 ms
コンパイル使用メモリ 73,688 KB
実行使用メモリ 56,424 KB
最終ジャッジ日時 2023-08-08 14:21:34
合計ジャッジ時間 5,778 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,928 KB
testcase_01 AC 120 ms
56,424 KB
testcase_02 AC 120 ms
56,160 KB
testcase_03 AC 119 ms
56,216 KB
testcase_04 AC 135 ms
56,300 KB
testcase_05 AC 119 ms
56,044 KB
testcase_06 AC 137 ms
56,348 KB
testcase_07 AC 137 ms
55,916 KB
testcase_08 AC 136 ms
56,168 KB
testcase_09 AC 136 ms
56,048 KB
testcase_10 AC 130 ms
56,096 KB
testcase_11 AC 136 ms
56,144 KB
testcase_12 AC 137 ms
55,904 KB
testcase_13 AC 136 ms
56,056 KB
testcase_14 AC 136 ms
56,252 KB
testcase_15 AC 139 ms
56,120 KB
testcase_16 AC 138 ms
55,744 KB
testcase_17 AC 138 ms
55,728 KB
testcase_18 AC 135 ms
55,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long w = sc.nextInt();
        long h = sc.nextInt();
        int n = sc.nextInt();
        HashSet<Integer> suits = new HashSet<>();
        HashSet<Integer> numbers = new HashSet<>();
        for (int i = 0; i < n; i++) {
            suits.add(sc.nextInt());
            numbers.add(sc.nextInt());
        }
        long wCount = suits.size();
        long hCount = numbers.size();
        long ans = wCount * h + hCount * w - wCount * hCount - n;
        System.out.println(ans);
    }
}
0