結果

問題 No.11 カードマッチ
ユーザー shinshin
提出日時 2022-05-17 18:19:18
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,384 bytes
コンパイル時間 4,818 ms
コンパイル使用メモリ 75,516 KB
実行使用メモリ 764,092 KB
最終ジャッジ日時 2023-10-13 17:16:56
合計ジャッジ時間 13,520 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
49,228 KB
testcase_01 AC 39 ms
49,368 KB
testcase_02 AC 40 ms
49,308 KB
testcase_03 AC 40 ms
49,420 KB
testcase_04 MLE -
testcase_05 AC 111 ms
49,128 KB
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 AC 127 ms
114,700 KB
testcase_16 MLE -
testcase_17 AC 201 ms
223,624 KB
testcase_18 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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 , count = 0;
		Queue<Integer> qu = new ArrayDeque<>();
		
		int[][] hand = new int[W + 1][H + 1];
		for(int i = 0;i < N;i++) {
			S = Integer.parseInt(text[i + 3].split(" ")[0]);
			K = Integer.parseInt(text[i + 3].split(" ")[1]);
			
			hand[S][K] = 1;
			qu.add(S);
			qu.add(K);
		}
		
		for(int i = 0;i < N;i++) {
			S = qu.poll();
			K = qu.poll();
			
			for(int kn = 1;kn <= H;kn++) {
				if(hand[S][kn] != 1) {
					count++;
					hand[S][kn] = 1;
				}
			}
			for(int sn = 1;sn <= W;sn++) {
				if(hand[sn][K] != 1) {
					count++;
					hand[sn][K] = 1;
				}
			}
		}
		
		System.out.println(count);

	}
	
	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