結果

問題 No.11 カードマッチ
ユーザー scachescache
提出日時 2014-11-12 03:32:48
言語 Java19
(openjdk 21)
結果
AC  
実行時間 141 ms / 5,000 ms
コード長 932 bytes
コンパイル時間 2,914 ms
コンパイル使用メモリ 73,720 KB
実行使用メモリ 58,080 KB
最終ジャッジ日時 2023-08-01 23:33:19
合計ジャッジ時間 5,315 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
56,096 KB
testcase_01 AC 118 ms
56,020 KB
testcase_02 AC 112 ms
55,400 KB
testcase_03 AC 111 ms
55,852 KB
testcase_04 AC 133 ms
56,456 KB
testcase_05 AC 117 ms
56,376 KB
testcase_06 AC 137 ms
57,928 KB
testcase_07 AC 134 ms
55,780 KB
testcase_08 AC 141 ms
57,772 KB
testcase_09 AC 135 ms
57,772 KB
testcase_10 AC 133 ms
58,080 KB
testcase_11 AC 139 ms
58,040 KB
testcase_12 AC 139 ms
57,992 KB
testcase_13 AC 141 ms
55,720 KB
testcase_14 AC 140 ms
55,404 KB
testcase_15 AC 129 ms
55,732 KB
testcase_16 AC 134 ms
56,824 KB
testcase_17 AC 136 ms
56,004 KB
testcase_18 AC 131 ms
55,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] s = new int[n];
		int[] k = new int[n];
		for(int i=0;i<n;i++){
			s[i] = sc.nextInt();
			k[i] = sc.nextInt();
		}
		solve(w, h, s, k);
	}

	public void solve(int W, int H, int[] s, int[] k) {
		boolean[] mark = new boolean[W+1];
		boolean[] number = new boolean[H+1];
		
		for(int i=0;i<s.length;i++){
			mark[s[i]] = true;
			number[k[i]] = true;
		}
		
		long markNum = 0;
		for(int i=0;i<mark.length;i++){
			if(mark[i])
				markNum++;
		}
		long numNum = 0;
		for(int i=0;i<number.length;i++){
			if(number[i])
				numNum++;
		}

		long res = markNum*H+numNum*W-markNum*numNum-s.length;
		
		System.out.println(res);
		
	}

}
0