結果

問題 No.11 カードマッチ
ユーザー htensai
提出日時 2019-12-30 17:15:39
言語 Java
(openjdk 23)
結果
AC  
実行時間 154 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 2,818 ms
コンパイル使用メモリ 75,176 KB
実行使用メモリ 41,784 KB
最終ジャッジ日時 2024-11-08 20:03:06
合計ジャッジ時間 6,565 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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