《 1<=u<=v<=n》

蒙自市凤凰小学又阝十尃亻二  •  1年前


include <bits/stdc++.h>

using namespace std; bool table[10006];

int main() {

/*freopen("LongStree.in","r",stdin);
freopen("LongStree.out","w",stdout);*/
int n, m, ans, u, v;
cin >> n >> m;
ans = n * 4 + 4;
for (int i = 0; i < m; i++) {
	cin >> u >> v;
	for (int j = u; j <= v; j++) {
		if (table[j] == 0) {
			table[j] = 1;
		}
	}
}
for (int i = 1; i <= n; i++) {
	if (table[i])
		ans--;
}
cout << ans<<endl;
return 0;

} //一开始没考虑重叠,30分(大悲) //然后又被数据范围坑,90(恼


评论:

请先登录,才能进行评论