結果

問題 No.606 カラフルタイル
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-01 14:09:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,536 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 4,320 ms
コンパイル使用メモリ 76,572 KB
実行使用メモリ 66,160 KB
最終ジャッジ日時 2024-05-05 22:25:11
合計ジャッジ時間 20,502 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,696 KB
testcase_01 AC 131 ms
41,288 KB
testcase_02 AC 132 ms
42,040 KB
testcase_03 AC 134 ms
41,432 KB
testcase_04 AC 136 ms
41,240 KB
testcase_05 AC 134 ms
41,384 KB
testcase_06 AC 133 ms
41,168 KB
testcase_07 AC 133 ms
41,512 KB
testcase_08 AC 134 ms
41,220 KB
testcase_09 AC 135 ms
41,492 KB
testcase_10 AC 138 ms
41,524 KB
testcase_11 AC 131 ms
41,972 KB
testcase_12 AC 154 ms
41,556 KB
testcase_13 AC 324 ms
48,304 KB
testcase_14 AC 145 ms
42,188 KB
testcase_15 AC 218 ms
44,500 KB
testcase_16 AC 875 ms
58,240 KB
testcase_17 AC 1,374 ms
64,524 KB
testcase_18 AC 878 ms
58,732 KB
testcase_19 AC 831 ms
64,400 KB
testcase_20 AC 1,521 ms
65,704 KB
testcase_21 AC 909 ms
60,552 KB
testcase_22 AC 908 ms
60,252 KB
testcase_23 AC 1,074 ms
61,412 KB
testcase_24 AC 1,393 ms
64,644 KB
testcase_25 AC 1,378 ms
65,756 KB
testcase_26 AC 1,392 ms
65,120 KB
testcase_27 AC 1,536 ms
66,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    int k = sc.nextInt();
    int q = sc.nextInt();
    int[] row = new int[(int)n];
    int[] column = new int[(int)n];
    int r = 0;
    int c = 0;
    String[] a = new String[q];
    int[] B = new int[q];
    int[] C = new int[q];
    for(int i = 0; i < q; i++) {
      a[i] = sc.next();
      B[i] = sc.nextInt() - 1;
      C[i] = sc.nextInt() - 1;
    }
    long[] ans = new long[k];
    for(int i = q - 1; i >= 0; i--) {
      if(a[i].equals("R")) {
        if(row[B[i]] == 1) {
          
        } else {
          row[B[i]]++;
          r++;
          ans[C[i]] += (n - c);
        }
      } else {
        if(column[B[i]] == 1) {
          
        } else {
          column[B[i]]++;
          c++;
          ans[C[i]] += (n - r);
        }        
      }
    }
    long sum = 0;
    for(int i = 0; i < k; i++) {
      sum += ans[i];
    }
    ans[0] += (n * n - sum);
    for(int i = 0; i < k; i++) {
      System.out.println(ans[i]);
    }
  }
}
0