結果

問題 No.945 YKC饅頭
ユーザー Mayimg
提出日時 2020-07-24 22:46:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 325 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 2,526 ms
コンパイル使用メモリ 212,608 KB
最終ジャッジ日時 2025-01-12 05:09:58
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 74
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
map<char, int> conv = {{'Y', 0}, {'K', 1}, {'C', 2}};
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> a(n + 1), b(n + 1);
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    char ch;
    cin >> ch;
    a[l].emplace_back(i, conv[ch]);
    b[r + 1].emplace_back(i, conv[ch]);
  }
  set<pair<int, int>> st;
  vector<int> ans(3);
  for (int i = 0; i < n; i++) {
    for (auto& p : b[i]) st.erase(p);
    for (auto& p : a[i]) st.insert(p);
    if (st.empty()) continue;
    ans[st.begin()->second]++;
  }
  cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
  return 0;
}
0