結果

問題 No.606 カラフルタイル
ユーザー kk
提出日時 2021-05-03 01:52:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 209,224 KB
実行使用メモリ 5,400 KB
最終ジャッジ日時 2023-09-28 16:25:54
合計ジャッジ時間 4,929 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 18 ms
4,812 KB
testcase_17 AC 145 ms
5,216 KB
testcase_18 AC 19 ms
4,776 KB
testcase_19 AC 19 ms
4,776 KB
testcase_20 AC 148 ms
5,400 KB
testcase_21 AC 20 ms
4,924 KB
testcase_22 AC 20 ms
4,808 KB
testcase_23 AC 37 ms
4,748 KB
testcase_24 AC 108 ms
5,132 KB
testcase_25 AC 146 ms
5,216 KB
testcase_26 AC 147 ms
5,064 KB
testcase_27 AC 146 ms
5,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k, q;
  cin >> n >> k >> q;

  vector<tuple<char, int, int> > v;
  for (int i = 0; i < q; i++) {
    char a;
    int b, c;
    cin >> a >> b >> c;
    v.emplace_back(a, --b, --c);
  }

  vector<long long> cnt(k);
  vector<bool> rused(n), cused(n);
  long long nr = n;
  long long nc = n;
  for (int i = q-1; i >= 0; i--) {
    char a;
    int b, c;
    tie(a, b, c) = v[i];
    
    if (a == 'R') {
      if (!rused[b]) {
        rused[b] = true;
        cnt[c] += nc;
        --nr;
      }
    } else {

      if (!cused[b]) {
        cused[b] = true;
        cnt[c] += nr;
        --nc;
      }
    }
  }

  cnt[0] += nr * nc;
  for (int i = 0; i < k; i++)
    cout << cnt[i] << endl;
  
  return 0;
}
0