結果
問題 |
No.11 カードマッチ
|
ユーザー |
|
提出日時 | 2022-05-17 18:19:18 |
言語 | Java (openjdk 23) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,384 bytes |
コンパイル時間 | 3,791 ms |
コンパイル使用メモリ | 78,820 KB |
実行使用メモリ | 742,728 KB |
最終ジャッジ日時 | 2024-09-15 13:12:21 |
合計ジャッジ時間 | 15,644 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 MLE * 12 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Queue; 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 , count = 0; Queue<Integer> qu = new ArrayDeque<>(); int[][] hand = new int[W + 1][H + 1]; for(int i = 0;i < N;i++) { S = Integer.parseInt(text[i + 3].split(" ")[0]); K = Integer.parseInt(text[i + 3].split(" ")[1]); hand[S][K] = 1; qu.add(S); qu.add(K); } for(int i = 0;i < N;i++) { S = qu.poll(); K = qu.poll(); for(int kn = 1;kn <= H;kn++) { if(hand[S][kn] != 1) { count++; hand[S][kn] = 1; } } for(int sn = 1;sn <= W;sn++) { if(hand[sn][K] != 1) { count++; hand[sn][K] = 1; } } } System.out.println(count); } 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; } }