一种比题解set更简单的做法multiset
查看原帖
一种比题解set更简单的做法multiset
1068928
zhuzilin楼主2025/8/29 20:39
#include <bits/stdc++.h>
using namespace std;

struct Plan 
{
    int l, r;
    bool operator < (const Plan & p) const
    {
    	return r < p.l;
	}
};
int T;
multiset<Plan> s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> T;
    while (T--){
        char c;
        cin >> c;
        if(c == 'A'){
        	int l,r,cnt = 0;
        	cin >> l >> r; 
			Plan tmp = Plan{l,r};
			cout << s.count(tmp) << "\n";
			while(s.count(tmp)) s.erase(tmp); 
			s.insert(tmp);
		}
		else cout << s.size() << "\n";
    }
    return 0;
}
2025/8/29 20:39
加载中...