結果

問題 No.606 カラフルタイル
ユーザー takeya_okino
提出日時 2019-09-01 14:09:39
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,403 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 2,258 ms
コンパイル使用メモリ 77,072 KB
実行使用メモリ 67,388 KB
最終ジャッジ日時 2024-11-27 23:47:28
合計ジャッジ時間 18,270 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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