結果
| 問題 |
No.11 カードマッチ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-17 18:41:42 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 5,000 ms |
| コード長 | 1,185 bytes |
| コンパイル時間 | 3,764 ms |
| コンパイル使用メモリ | 78,776 KB |
| 実行使用メモリ | 37,144 KB |
| 最終ジャッジ日時 | 2024-09-15 13:35:58 |
| 合計ジャッジ時間 | 5,514 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class No11 {
public static void main(String[] args) throws IOException{
//カードマッチ
String[] text = readStr();
int W = Integer.parseInt(text[0]);
int H = Integer.parseInt(text[1]);
int N = Integer.parseInt(text[2]);
int S , K;
Long count = 0l;
ArrayList<Integer> wlist = new ArrayList<>() , hlist = new ArrayList<>();
for(int i = 0;i < N;i++) {
S = Integer.parseInt(text[i + 3].split(" ")[0]);
K = Integer.parseInt(text[i + 3].split(" ")[1]);
if(!wlist.contains(S)) wlist.add(S);
if(!hlist.contains(K)) hlist.add(K);
}
count = Math.multiplyExact((long)(W - wlist.size()), H - hlist.size());
System.out.println(Math.multiplyExact((long)W, H) - count - N);
}
public static String[] readStr() throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<>();
do {
list.add(br.readLine());
}while(br.ready());
br.close();
String[] text = new String[list.size()];
list.toArray(text);
return text;
}
}