結果

問題 No.606 カラフルタイル
ユーザー penguinshunyapenguinshunya
提出日時 2019-07-21 20:04:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 212,848 KB
実行使用メモリ 9,764 KB
最終ジャッジ日時 2023-09-05 02:43:20
合計ジャッジ時間 6,573 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 6 ms
4,384 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 42 ms
4,740 KB
testcase_17 AC 223 ms
9,764 KB
testcase_18 AC 86 ms
8,788 KB
testcase_19 AC 78 ms
8,236 KB
testcase_20 AC 224 ms
8,684 KB
testcase_21 AC 84 ms
8,096 KB
testcase_22 AC 84 ms
8,328 KB
testcase_23 AC 110 ms
7,244 KB
testcase_24 AC 185 ms
7,672 KB
testcase_25 AC 184 ms
5,156 KB
testcase_26 AC 220 ms
9,608 KB
testcase_27 AC 221 ms
9,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<tuple<int, int, int>> ve;

  for (int i = 0; i < q; i++) {
    char a;
    int b, c;
    cin >> a >> b >> c;
    b--, c--;
    ve.emplace_back(a == 'R', b, c);
  }
  reverse(ve.begin(), ve.end());

  vector<long long> ans(k);
  set<int> mar, mac;

  for (auto v : ve) {
    int x, b, c;
    tie(x, b, c) = v;
    if (x) {
      if (mar.count(b) == 0) {
        ans[c] += n - mac.size();
        mar.insert(b);
      }
    } else {
      if (mac.count(b) == 0) {
        ans[c] += n - mar.size();
        mac.insert(b);
      }
    }
  }
  
  ans[0] += (long long) (n - mac.size()) * (n - mar.size());
  for (int i = 0; i < k; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}
0