結果

問題 No.11 カードマッチ
ユーザー Flere0114
提出日時 2016-02-24 15:55:45
言語 Java
(openjdk 23)
結果
MLE  
実行時間 -
コード長 947 bytes
コンパイル時間 3,552 ms
コンパイル使用メモリ 77,680 KB
実行使用メモリ 762,548 KB
最終ジャッジ日時 2024-09-22 13:20:35
合計ジャッジ時間 14,141 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 MLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No11 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w, h, n;
        long ans = 0;
        w = sc.nextInt();
        h = sc.nextInt();
        n = sc.nextInt();
        int[] s = new int[n], k = new int[n];
        boolean[][] po = new boolean[w][h];

        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt() - 1;
            k[i] = sc.nextInt() - 1;
            po[s[i]][k[i]] = true;
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < h; j++) {
                if(!po[s[i]][j]){
                    ans++;
                    po[s[i]][j] = true;
                }
            }
            for (int j = 0; j < w; j++) {
                if(!po[j][k[i]]){
                    ans++;
                    po[j][k[i]] = true;
                }
            }
        }

        System.out.println(ans);
    }
}
0