結果

問題 No.606 カラフルタイル
ユーザー tentententen
提出日時 2020-09-06 16:12:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 921 ms / 2,000 ms
コード長 1,268 bytes
コンパイル時間 2,987 ms
コンパイル使用メモリ 73,068 KB
実行使用メモリ 71,856 KB
最終ジャッジ日時 2023-08-19 14:01:10
合計ジャッジ時間 17,354 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,592 KB
testcase_01 AC 123 ms
56,160 KB
testcase_02 AC 123 ms
55,912 KB
testcase_03 AC 124 ms
55,644 KB
testcase_04 AC 125 ms
55,952 KB
testcase_05 AC 127 ms
55,816 KB
testcase_06 AC 124 ms
55,416 KB
testcase_07 AC 124 ms
55,376 KB
testcase_08 AC 124 ms
55,668 KB
testcase_09 AC 123 ms
56,024 KB
testcase_10 AC 152 ms
55,960 KB
testcase_11 AC 123 ms
56,268 KB
testcase_12 AC 146 ms
55,868 KB
testcase_13 AC 296 ms
60,376 KB
testcase_14 AC 126 ms
55,644 KB
testcase_15 AC 194 ms
59,232 KB
testcase_16 AC 692 ms
64,292 KB
testcase_17 AC 854 ms
69,780 KB
testcase_18 AC 791 ms
69,092 KB
testcase_19 AC 816 ms
66,904 KB
testcase_20 AC 878 ms
66,768 KB
testcase_21 AC 804 ms
69,224 KB
testcase_22 AC 802 ms
69,136 KB
testcase_23 AC 826 ms
66,384 KB
testcase_24 AC 849 ms
65,432 KB
testcase_25 AC 816 ms
64,428 KB
testcase_26 AC 853 ms
69,996 KB
testcase_27 AC 921 ms
71,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int k = sc.nextInt();
    	int q = sc.nextInt();
    	boolean[] isRows = new boolean[q];
    	int[] idxes = new int[q];
    	int[] colors = new int[q];
    	for (int i = 0; i < q; i++) {
    	    isRows[i] = (sc.next().charAt(0) == 'R');
    	    idxes[i] = sc.nextInt();
    	    colors[i] = sc.nextInt() - 1;
    	}
    	HashSet<Integer> rows = new HashSet<>();
    	HashSet<Integer> cols = new HashSet<>();
    	long[] ans = new long[k];
    	for (int i = q - 1; i >= 0; i--) {
    	    if (isRows[i]) {
    	        if (!rows.contains(idxes[i])) {
    	            ans[colors[i]] += n - cols.size();
    	            rows.add(idxes[i]);
    	        }
    	    } else {
    	        if (!cols.contains(idxes[i])) {
    	            ans[colors[i]] += n - rows.size();
    	            cols.add(idxes[i]);
    	        }
    	    }
    	}
    	long total = 0;
    	for (int i = 1; i < k; i++) {
    	    total += ans[i];
    	}
    	ans[0] = (long)n * n - total;
    	StringBuilder sb = new StringBuilder();
    	for (long x : ans) {
    	    sb.append(x).append("\n");
    	}
    	System.out.print(sb);
	}
}
0