結果

問題 No.945 YKC饅頭
ユーザー yuppe19 😺yuppe19 😺
提出日時 2019-12-08 10:07:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 1,357 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 52,280 KB
実行使用メモリ 4,788 KB
最終ジャッジ日時 2023-08-28 15:21:54
合計ジャッジ時間 5,499 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 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,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 5 ms
4,380 KB
testcase_33 AC 31 ms
4,684 KB
testcase_34 AC 39 ms
4,376 KB
testcase_35 AC 99 ms
4,700 KB
testcase_36 AC 50 ms
4,376 KB
testcase_37 AC 59 ms
4,380 KB
testcase_38 AC 69 ms
4,376 KB
testcase_39 AC 14 ms
4,376 KB
testcase_40 AC 12 ms
4,688 KB
testcase_41 AC 6 ms
4,376 KB
testcase_42 AC 111 ms
4,376 KB
testcase_43 AC 46 ms
4,376 KB
testcase_44 AC 59 ms
4,736 KB
testcase_45 AC 73 ms
4,384 KB
testcase_46 AC 4 ms
4,376 KB
testcase_47 AC 55 ms
4,380 KB
testcase_48 AC 12 ms
4,380 KB
testcase_49 AC 24 ms
4,376 KB
testcase_50 AC 139 ms
4,376 KB
testcase_51 AC 110 ms
4,688 KB
testcase_52 AC 104 ms
4,752 KB
testcase_53 AC 90 ms
4,744 KB
testcase_54 AC 96 ms
4,692 KB
testcase_55 AC 101 ms
4,732 KB
testcase_56 AC 6 ms
4,736 KB
testcase_57 AC 4 ms
4,688 KB
testcase_58 AC 79 ms
4,704 KB
testcase_59 AC 96 ms
4,752 KB
testcase_60 AC 36 ms
4,700 KB
testcase_61 AC 83 ms
4,788 KB
testcase_62 AC 81 ms
4,700 KB
testcase_63 AC 5 ms
4,740 KB
testcase_64 AC 39 ms
4,692 KB
testcase_65 AC 31 ms
4,688 KB
testcase_66 AC 29 ms
4,680 KB
testcase_67 AC 59 ms
4,696 KB
testcase_68 AC 36 ms
4,696 KB
testcase_69 AC 14 ms
4,788 KB
testcase_70 AC 17 ms
4,684 KB
testcase_71 AC 17 ms
4,692 KB
testcase_72 AC 47 ms
4,704 KB
testcase_73 AC 91 ms
4,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdint>
#include <cstdio>
#include <vector>
using namespace std;
using i64 = int64_t;

template <class T>
struct SegTree {
  int N;
  vector<T> dat;
  explicit SegTree(int n) {
    N = 1;
    while(N < n) { N <<= 1; }
    N <<= 1;
    dat.assign(N, 0);
  }
  void update(int a, int b, int k, int l, int r, int x) {
    if(k >= N) { return; }
    if(dat[k] != 0) { return; }
    if(b <= l || r <= a) { return; }
    update(a, b, 2*k+0, l, (l+r)/2, x);
    update(a, b, 2*k+1, (l+r)/2, r, x);
    if(a <= l && r <= b) {
      if(l+1 == r || (dat[2*k] == x && dat[2*k+1] == x)) {
        dat[k] = x;
      }
    }
  }
  void update(int a, int b, int x) {
    update(a, b, 1, 0, N/2, x);
  }
  void dump() {
    for(int i=0; i<N; ++i) {
      if(i) { fprintf(stderr, " "); }
      fprintf(stderr, "%d", dat[i]);
    }
    fprintf(stderr, "\n");
  }
  void solve() {
    vector<int> v(4);
    for(int i=N/2; i<N; ++i) {
      ++v[dat[i]];
    }
    printf("%d %d %d\n", v[1], v[2], v[3]);
  }
};

int main(void) {
  int N, M; scanf("%d%d", &N, &M);
  SegTree<int> tree(N);
  for(int i=0; i<M; ++i) {
    int a, b; char c; scanf("%d %d %c", &a, &b, &c);
    int x = 1;
    switch(c) {
      case 'K':
        x = 2;
        break;
      case 'C':
        x = 3;
        break;
    }
    --a;
    tree.update(a, b, x);
  }
  tree.solve();
  return 0;
}
0