結果

問題 No.11 カードマッチ
ユーザー atkrym
提出日時 2016-11-03 11:12:47
言語 Java
(openjdk 23)
結果
MLE  
実行時間 -
コード長 835 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 74,100 KB
実行使用メモリ 762,336 KB
最終ジャッジ日時 2024-11-25 02:25:02
合計ジャッジ時間 13,267 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 MLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        boolean[][] b = new boolean[w][h];
        long ret = 0;
        for (int i = 0;i < n;i++) {
            int s = sc.nextInt()-1;
            int k = sc.nextInt()-1;
            
            for (int j = 0;j < h;j++) {
                if (!b[s][j]) {
                    b[s][j] = true;
                    ret++;
                }
            }
            
            for (int j = 0;j < w;j++) {
                if (!b[j][k]) {
                    b[j][k] = true;
                    ret++;
                }
            }
        }
        System.out.println(ret-n);
    }
}
0