one_OIER @ 2022-07-05 16:18:21
#include <bits/stdc++.h>
using namespace std;
int n , m , l , r;
bool vis[10110];
int main() {
cin >> n >> m;
for(int i = 1;i <= n;++i) {
vis[i] = false;
}
while(m--) {
cin >> l >> r;
for(int i = l;i <= r;++i) {
vis[i] = true;
}
}
int ans = 0;
for(int i = 1;i <= n;++i) {
if(vis[i] == false) ans++;
}
cout << ans << endl;
return 0;
}
by StarLbright40 @ 2022-07-05 16:53:14
有没有可能是双闭
by one_OIER @ 2022-07-05 17:58:20
@PhantomKnight 嗯,真是神奇,改了一个++i就好了
by sheryang_WA @ 2022-07-12 11:14:17
@PhantomKnight 本来就是(0,n)(0到n)