結果

問題 No.11 カードマッチ
ユーザー shinshin
提出日時 2022-05-17 18:41:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 1,185 bytes
コンパイル時間 3,941 ms
コンパイル使用メモリ 75,156 KB
実行使用メモリ 50,716 KB
最終ジャッジ日時 2023-10-13 17:43:58
合計ジャッジ時間 5,652 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,300 KB
testcase_01 AC 44 ms
49,232 KB
testcase_02 AC 43 ms
49,416 KB
testcase_03 AC 44 ms
49,432 KB
testcase_04 AC 47 ms
49,244 KB
testcase_05 AC 43 ms
49,228 KB
testcase_06 AC 48 ms
49,712 KB
testcase_07 AC 50 ms
49,388 KB
testcase_08 AC 50 ms
50,716 KB
testcase_09 AC 50 ms
49,728 KB
testcase_10 AC 47 ms
49,296 KB
testcase_11 AC 49 ms
49,656 KB
testcase_12 AC 50 ms
49,304 KB
testcase_13 AC 47 ms
49,440 KB
testcase_14 AC 50 ms
49,440 KB
testcase_15 AC 50 ms
49,460 KB
testcase_16 AC 50 ms
49,304 KB
testcase_17 AC 49 ms
49,728 KB
testcase_18 AC 50 ms
49,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class No11 {

	public static void main(String[] args) throws IOException{
		//カードマッチ
		String[] text = readStr();
		int W = Integer.parseInt(text[0]);
		int H = Integer.parseInt(text[1]);
		int N = Integer.parseInt(text[2]);
		int S , K;
		Long count = 0l;
		ArrayList<Integer> wlist = new ArrayList<>() , hlist = new ArrayList<>();
		
		for(int i = 0;i < N;i++) {
			S = Integer.parseInt(text[i + 3].split(" ")[0]);
			K = Integer.parseInt(text[i + 3].split(" ")[1]);
			
			if(!wlist.contains(S)) wlist.add(S);
			if(!hlist.contains(K)) hlist.add(K);
			
		}
		count = Math.multiplyExact((long)(W - wlist.size()), H - hlist.size());
		System.out.println(Math.multiplyExact((long)W, H) - count - N);

	}
	
	public static String[] readStr() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<>();

		do {
			list.add(br.readLine());
		}while(br.ready());

		br.close();

		String[] text = new String[list.size()];
		list.toArray(text);

		return text;

	}

}
0