結果
| 問題 |
No.945 YKC饅頭
|
| コンテスト | |
| ユーザー |
Akidai
|
| 提出日時 | 2022-12-06 00:52:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 411 ms / 2,000 ms |
| コード長 | 1,838 bytes |
| コンパイル時間 | 4,392 ms |
| コンパイル使用メモリ | 260,404 KB |
| 最終ジャッジ日時 | 2025-02-09 05:36:01 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 74 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
#define All(A) A.begin(), A.end()
#define rAll(A) A.rbegin(), A.rend()
#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>
int N, M;
vvi Q;
void solve() {
vi ans(N, -1);
reverse(All(Q));
vector<vvi> A(N);
REP(i, 0, M) {
int l = Q[i][0], r = Q[i][1], c = Q[i][2];
A[l].push_back({i, r, c});
}
priority_queue<vi> P;
REP(i, 0, N) {
for(vi a: A[i]) {
P.push(a);
// cout << "pushed: " << a[0] << " " << a[1] << " " << a[2] << endl;
}
if(P.empty()) continue;
vi top = P.top();
int priority = top[0], r = top[1], c = top[2];
// cout << priority << " " << r << " " << c << endl;
while(r < i) {
P.pop();
if(P.empty()) {
c = -1;
break;
}
top = P.top();
priority = top[0], r = top[1], c = top[2];
}
ans[i] = c;
/*
REP(i, 0, N) cout << ans[i] << " ";
cout << endl;
*/
}
vi cnt(3, 0);
REP(i, 0, N) {
if(ans[i] == -1) continue;
cnt[ans[i]]++;
}
REP(i, 0, 3) {
cout << cnt[i] << " ";
}
cout << endl;
}
int main() {
cin >> N >> M;
Q.resize(M);
REP(i, 0, M) {
int l, r;
char t;
cin >> l >> r >> t;
l--; r--;
int c = 0;
if(t == 'K') c = 1;
if(t == 'C') c = 2;
Q[i] = {l, r, c};
}
solve();
}
Akidai