結果

問題 No.606 カラフルタイル
ユーザー kk
提出日時 2021-05-03 01:41:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 206,996 KB
実行使用メモリ 6,508 KB
最終ジャッジ日時 2023-09-28 16:12:49
合計ジャッジ時間 5,935 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 11 ms
5,676 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 20 ms
6,016 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 15 ms
4,376 KB
testcase_17 AC 152 ms
5,052 KB
testcase_18 AC 24 ms
4,512 KB
testcase_19 AC 23 ms
4,412 KB
testcase_20 AC 175 ms
6,364 KB
testcase_21 AC 44 ms
5,820 KB
testcase_22 AC 44 ms
5,784 KB
testcase_23 AC 58 ms
5,680 KB
testcase_24 AC 119 ms
6,508 KB
testcase_25 AC 152 ms
6,368 KB
testcase_26 AC 153 ms
6,360 KB
testcase_27 AC 156 ms
6,468 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<int> rt(n), rc(n);
  vector<int> ct(n), cc(n);

  for (int i = 0; i < n; i++) {
    rt[i] = i;
    ct[i] = n + i;
  }
  
  for (int i = 2 * n; i < 2 * n + q; i++) {
    char a;
    int b, c;
    cin >> a >> b >> c;
    --b, --c;
    if (a == 'R') {
      rt[b] = i;
      rc[b] = c;
    } else {
      ct[b] = i;
      cc[b] = c;
    }
  }

  vector<int> rtset, ctset;
  for (int i = 0; i < n; i++) {
    rtset.push_back(rt[i]);
    ctset.push_back(ct[i]);
  }
  sort(rtset.begin(), rtset.end());
  sort(ctset.begin(), ctset.end());
  
  vector<long long> cnt(k);
  for (int i = 0; i < n; i++) {
    int tmp = n - (ctset.end() - lower_bound(ctset.begin(), ctset.end(), rt[i]));
    cnt[rc[i]] += tmp;
  }
  for (int i = 0; i < n; i++) {
    int tmp = n - (rtset.end() - lower_bound(rtset.begin(), rtset.end(), ct[i]));
    cnt[cc[i]] += tmp;
  }
  for (int i = 0; i < k; i++)
    cout << cnt[i] << endl;
  
  return 0;
}
0