結果

問題 No.11 カードマッチ
ユーザー mastersatoshimastersatoshi
提出日時 2015-08-03 17:36:35
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,292 bytes
コンパイル時間 2,720 ms
コンパイル使用メモリ 77,964 KB
実行使用メモリ 50,540 KB
最終ジャッジ日時 2024-04-20 01:06:13
合計ジャッジ時間 3,975 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,296 KB
testcase_01 AC 49 ms
50,540 KB
testcase_02 AC 51 ms
50,260 KB
testcase_03 AC 50 ms
50,300 KB
testcase_04 AC 53 ms
49,960 KB
testcase_05 AC 50 ms
50,300 KB
testcase_06 AC 52 ms
49,928 KB
testcase_07 AC 53 ms
50,256 KB
testcase_08 AC 55 ms
50,392 KB
testcase_09 AC 54 ms
50,036 KB
testcase_10 AC 52 ms
50,344 KB
testcase_11 AC 51 ms
49,988 KB
testcase_12 AC 51 ms
50,072 KB
testcase_13 AC 52 ms
50,080 KB
testcase_14 AC 51 ms
50,236 KB
testcase_15 AC 51 ms
50,036 KB
testcase_16 AC 51 ms
50,300 KB
testcase_17 AC 52 ms
50,400 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int w = Integer.parseInt(br.readLine());
        int h = Integer.parseInt(br.readLine());
        int n = Integer.parseInt(br.readLine());

        TreeMap<Integer, Integer> s = new TreeMap();
        TreeMap<Integer, Integer> k = new TreeMap();

        long count = 0;
        for (int i = 0; i < n; i++) {
            long tmpCount = 0;
            String[] tmp = br.readLine().split(" ");
            int[] tmpSk = new int[]{Integer.parseInt(tmp[0]),
                Integer.parseInt(tmp[1])};

            if (!s.containsKey(tmpSk[0]) && !k.containsKey(tmpSk[1])) {
                tmpCount = w + h - 2 - s.size() - k.size();
                s.put(tmpSk[0], 0);
                k.put(tmpSk[1], 0);
            } else if (s.containsKey(tmpSk[0])) {
                tmpCount = w - 2 - (s.size() - 1);
                k.put(tmpSk[1], 0);
            } else if (k.containsKey(tmpSk[1])) {
                tmpCount = h - 2 - (k.size() - 1);
                s.put(tmpSk[0], 0);
            }

            count += tmpCount;
        }

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