結果
| 問題 |
No.11 カードマッチ
|
| コンテスト | |
| ユーザー |
mastersatoshi
|
| 提出日時 | 2015-08-03 17:36:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,292 bytes |
| コンパイル時間 | 2,348 ms |
| コンパイル使用メモリ | 78,236 KB |
| 実行使用メモリ | 37,116 KB |
| 最終ジャッジ日時 | 2024-10-11 19:53:49 |
| 合計ジャッジ時間 | 3,875 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 1 |
ソースコード
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);
}
}
mastersatoshi