結果

問題 No.945 YKC饅頭
ユーザー 00 Sakuda
提出日時 2024-04-05 00:15:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 302 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 201,312 KB
最終ジャッジ日時 2025-02-20 20:11:07
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 74
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M;cin >> N >> M;
	set<int> non;
	for (int i = 1;i <= N;i++) non.insert(i);
	vector<int> ans(3, 0);
	while (M--) {
		int l, r;char c;cin >> l >> r >> c;
		int v = 0;
		if (c == 'K') {
			v = 1;
		} else if (c == 'C') {
			v = 2;
		}
		auto itr = non.lower_bound(l);
		vector<int> er;
		while (itr != non.end()) {
			if (*itr > r) break;
			er.push_back(*itr);
			itr++;
		}
		for (auto nv : er) non.erase(nv);
		ans[v] += (int)er.size();
	}
	cout << ans[0] << " "<< ans[1] << " " << ans[2] << endl;
}
0