前两个WA了
查看原帖
前两个WA了
1086908
CowNow9490楼主2023/9/22 21:19

模拟。

#include <bits/stdc++.h>
using namespace std;

int main(){
	
	int L,M,T=0;
	int start[100], end[100];
	bool tree[10007];
	memset(tree, false, sizeof(tree));
	
	cin>>L>>M;
	for(int i=1; i<=M; i++)
	{
		cin>>start[i]>>end[i];
		if(start[i]>end[i] || start[i]<0 || end[i]>L) goto exit;
		fill(tree+start[i], tree+end[i], true); 
	}
	
	for(int i=1; i<=L; i++)
	{
		if(tree[i]==false) T+=1;
	}
	cout << T;
	
	exit:
	return 0; 
}
2023/9/22 21:19
加载中...