文章

59

粉丝

0

获赞

340

访问

14.3k

头像
剩下的树 题解:easy map
P1175 清华大学上机题
发布于2026年3月12日 01:13
阅读数 299

#include <iostream>
#include <map>
using namespace std;

int main()
{
	int L,M;
	while(cin>>L>>M)
	{
		map<int,int> tree;
		for(int i=0;i<=L;i++)
			tree[i]++;
		for(int i=0;i<M;i++)
		{
			int a,b;
			cin>>a>>b;
			for(int j=a;j<=b;j++)
				tree[j]--;
		}
		int count=0;
		for(int i=0;i<=L;i++)
			if(tree[i]==1)
			   count++;
		cout<<count<<endl;
	}
	return 0;
}	   

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发