結果

問題 No.11 カードマッチ
ユーザー rn4ru
提出日時 2016-04-13 02:18:46
言語 Java
(openjdk 23)
結果
MLE  
実行時間 -
コード長 935 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 76,756 KB
実行使用メモリ 761,996 KB
最終ジャッジ日時 2024-10-04 06:44:34
合計ジャッジ時間 13,917 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 MLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int W = scanner.nextInt();
		int H = scanner.nextInt();
		int N = scanner.nextInt();
		boolean[][] hands = new boolean[W + 1][H + 1];
		boolean[][] covered = new boolean[W + 1][H + 1];
		for (int i = 0; i < N; i++) {
			int S = scanner.nextInt();
			int K = scanner.nextInt();
			hands[S][K] = true;
			covered[S][K] = true;
		}

		long match = 0;
		for (int i = 1; i <= W; i++) {
			boolean found = false;
			for (int j = 1; j <= H; j++) {
				if (hands[i][j]) {
					found = true;
					for (int k = 1; k <= W; k++) {
						if (!covered[k][j]) {
							covered[k][j] = true;
							match++;
						}
					}
				}
			}
			if (!found)
				continue;

			for (int k = 1; k <= H; k++) {
				if (!covered[i][k]) {
					covered[i][k] = true;
					match++;
				}
			}
		}
		System.out.println(match);
	}

}
0