結果

問題 No.11 カードマッチ
コンテスト
ユーザー Grenache
提出日時 2015-11-03 14:09:58
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 76 ms / 5,000 ms
コード長 687 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,609 ms
コンパイル使用メモリ 83,040 KB
実行使用メモリ 42,748 KB
最終ジャッジ日時 2026-04-28 04:46:59
合計ジャッジ時間 5,938 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class Main_yukicoder11 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();

        Set<Integer> hsw = new HashSet<Integer>();
        Set<Integer> hsh = new HashSet<Integer>();

        for (int i = 0; i < n; i++) {
        	int s = sc.nextInt();
        	int k = sc.nextInt();
        	hsw.add(s);
        	hsh.add(k);
        }

        System.out.println((long)hsw.size() * h + hsh.size() * w - (long)hsw.size() * hsh.size() - n);
        
        sc.close();
    }
}
0