結果

問題 No.945 YKC饅頭
ユーザー iqueue02
提出日時 2019-12-11 16:07:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 939 bytes
コンパイル時間 2,059 ms
コンパイル使用メモリ 184,468 KB
実行使用メモリ 16,932 KB
最終ジャッジ日時 2024-06-24 07:41:42
合計ジャッジ時間 8,580 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 74
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;

int main(){
  int n, m;
  cin >> n >> m;
  
  priority_queue<pair<int,P>, vector<pair<int,P>>, greater<>> que;
  vector<vector<pair<int,P>>> ykc(n);
  map<char,int> mp;

  mp['Y'] = 0;
  mp['K'] = 1;
  mp['C'] = 2;

  rep(i,m) {
   int l, r;
   char c;
   cin >> l >> r >> c;
   int num = mp[c];
   l--; r--;
   ykc[l].emplace_back(make_pair(i,make_pair(r,num)));
  }

  vector<int> check(n,0), res(3,0);

  for (int i = 0; i < n; i++) {
    for (auto e : ykc[i]) que.push(e);

    while (!que.empty() && !check[i]) {
      auto p = que.top(); 
      if (p.second.first < i) que.pop();
      else {
        check[i] = 1;
        res[p.second.second]++;
      }  
    }  
  }
  for (auto ans : res) cout << ans << " ";
  cout << endl;
  return 0;
}
0