結果
| 問題 |
No.606 カラフルタイル
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-09-06 16:12:40 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,094 ms / 2,000 ms |
| コード長 | 1,268 bytes |
| コンパイル時間 | 2,385 ms |
| コンパイル使用メモリ | 79,724 KB |
| 実行使用メモリ | 67,092 KB |
| 最終ジャッジ日時 | 2024-11-29 07:15:28 |
| 合計ジャッジ時間 | 17,634 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
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);
}
}
tenten