結果
問題 | No.606 カラフルタイル |
ユーザー | tenten |
提出日時 | 2021-11-12 13:59:54 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 340 ms / 2,000 ms |
コード長 | 2,341 bytes |
コンパイル時間 | 2,201 ms |
コンパイル使用メモリ | 78,736 KB |
実行使用メモリ | 67,100 KB |
最終ジャッジ日時 | 2024-11-24 23:57:07 |
合計ジャッジ時間 | 8,724 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
50,108 KB |
testcase_01 | AC | 48 ms
50,224 KB |
testcase_02 | AC | 48 ms
50,168 KB |
testcase_03 | AC | 48 ms
49,820 KB |
testcase_04 | AC | 49 ms
49,888 KB |
testcase_05 | AC | 49 ms
49,980 KB |
testcase_06 | AC | 49 ms
49,948 KB |
testcase_07 | AC | 49 ms
49,744 KB |
testcase_08 | AC | 49 ms
50,524 KB |
testcase_09 | AC | 52 ms
50,096 KB |
testcase_10 | AC | 51 ms
49,980 KB |
testcase_11 | AC | 53 ms
50,176 KB |
testcase_12 | AC | 51 ms
50,036 KB |
testcase_13 | AC | 128 ms
54,284 KB |
testcase_14 | AC | 50 ms
50,308 KB |
testcase_15 | AC | 84 ms
50,884 KB |
testcase_16 | AC | 227 ms
57,256 KB |
testcase_17 | AC | 333 ms
65,948 KB |
testcase_18 | AC | 280 ms
60,772 KB |
testcase_19 | AC | 261 ms
62,492 KB |
testcase_20 | AC | 340 ms
62,608 KB |
testcase_21 | AC | 294 ms
62,096 KB |
testcase_22 | AC | 291 ms
63,060 KB |
testcase_23 | AC | 303 ms
64,008 KB |
testcase_24 | AC | 330 ms
62,556 KB |
testcase_25 | AC | 293 ms
58,688 KB |
testcase_26 | AC | 330 ms
67,100 KB |
testcase_27 | AC | 323 ms
65,284 KB |
ソースコード
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); int q = sc.nextInt(); long total = (long)n * n; boolean[] isRows = new boolean[q]; int[] nums = new int[q]; int[] colors = new int[q]; for (int i = 0; i < q; i++) { isRows[i] = (sc.next().charAt(0) == 'R'); nums[i] = sc.nextInt(); colors[i] = sc.nextInt() - 1; } int rowCount = n; int colCount = n; HashSet<Integer> rowUsed = new HashSet<>(); HashSet<Integer> colUsed = new HashSet<>(); long[] counts = new long[k]; for (int i = q - 1; i >= 0; i--) { if (isRows[i]) { if (rowUsed.contains(nums[i])) { continue; } rowUsed.add(nums[i]); rowCount--; counts[colors[i]] += colCount; total -= colCount; } else { if (colUsed.contains(nums[i])) { continue; } colUsed.add(nums[i]); colCount--; counts[colors[i]] += rowCount; total -= rowCount; } } counts[0] += total; StringBuilder sb = new StringBuilder(); for (long x : counts) { sb.append(x).append("\n"); } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }