結果

問題 No.606 カラフルタイル
ユーザー たこしたこし
提出日時 2017-12-16 11:04:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 1,187 ms
コンパイル使用メモリ 150,588 KB
実行使用メモリ 10,136 KB
最終ジャッジ日時 2023-08-21 09:05:51
合計ジャッジ時間 4,776 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 42 ms
5,184 KB
testcase_17 AC 203 ms
9,888 KB
testcase_18 AC 61 ms
9,176 KB
testcase_19 AC 59 ms
8,884 KB
testcase_20 AC 210 ms
8,576 KB
testcase_21 AC 64 ms
7,752 KB
testcase_22 AC 64 ms
7,940 KB
testcase_23 AC 88 ms
7,508 KB
testcase_24 AC 162 ms
7,852 KB
testcase_25 AC 190 ms
5,120 KB
testcase_26 AC 206 ms
10,136 KB
testcase_27 AC 205 ms
9,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using LL = long long int;

#define int long long

const int MAX_N = 100005;

int N;
int K;
int Q;

char A[MAX_N];
int B[MAX_N], C[MAX_N];
int Ans[MAX_N];

signed main()
{
  cin >> N >> K >> Q;
  for(int i = 0; i < Q; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }

  int rr = 0;
  int cc = 0;
  int S = 0;
  unordered_set<int> RSet, CSet;

  for(int q = Q-1; 0 <= q; q--) {
    if(A[q] == 'R') {
      if(RSet.insert(B[q]).second) {
        Ans[C[q]] += N - cc;
        rr++;
      }
    } else {
      if(CSet.insert(B[q]).second) {
        Ans[C[q]] += N - rr;
        cc++;
      }
    }
  }

  for(int i = 1; i <= K; i++) {
    S += Ans[i];
  }
  Ans[1] += N*N - S;

  for(int i = 1; i <= K; i++) {
    cout << Ans[i] << endl;
  }

  return 0;
}
0