Run ID:119788
提交时间:2025-05-18 20:46:29
#include <iostream> #include <vector> using namespace std; int main() { int L, M; cin >> L >> M; vector<bool> removed(L + 1, false); for (int i = 0; i < M; ++i) { int start, end; cin >> start >> end; if (start > end) { swap(start, end); } for (int j = start; j <= end; ++j) { removed[j] = true; } } int count = 0; for (int i = 0; i <= L; ++i) { if (!removed[i]) { ++count; } } cout << count << endl; return 0; }