結果

問題 No.606 カラフルタイル
ユーザー htensaihtensai
提出日時 2019-11-14 12:35:25
言語 Java19
(openjdk 21)
結果
AC  
実行時間 903 ms / 2,000 ms
コード長 1,206 bytes
コンパイル時間 2,326 ms
コンパイル使用メモリ 79,852 KB
実行使用メモリ 79,456 KB
最終ジャッジ日時 2023-10-21 19:57:49
合計ジャッジ時間 16,542 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,584 KB
testcase_01 AC 131 ms
57,396 KB
testcase_02 AC 132 ms
57,616 KB
testcase_03 AC 132 ms
57,260 KB
testcase_04 AC 133 ms
57,360 KB
testcase_05 AC 133 ms
57,576 KB
testcase_06 AC 120 ms
56,176 KB
testcase_07 AC 130 ms
57,452 KB
testcase_08 AC 131 ms
57,384 KB
testcase_09 AC 130 ms
57,316 KB
testcase_10 AC 132 ms
57,364 KB
testcase_11 AC 129 ms
57,232 KB
testcase_12 AC 154 ms
57,548 KB
testcase_13 AC 317 ms
62,208 KB
testcase_14 AC 133 ms
57,380 KB
testcase_15 AC 206 ms
60,580 KB
testcase_16 AC 760 ms
71,188 KB
testcase_17 AC 901 ms
78,940 KB
testcase_18 AC 802 ms
76,920 KB
testcase_19 AC 804 ms
74,052 KB
testcase_20 AC 903 ms
68,016 KB
testcase_21 AC 837 ms
72,780 KB
testcase_22 AC 831 ms
74,152 KB
testcase_23 AC 861 ms
73,640 KB
testcase_24 AC 883 ms
74,928 KB
testcase_25 AC 846 ms
68,040 KB
testcase_26 AC 892 ms
79,456 KB
testcase_27 AC 886 ms
78,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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