Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <cstdlib>
- #include <algorithm>
- #include <cmath>
- #include <iomanip>
- #include <numeric>
- #include <vector>
- using namespace std;
- #define ll long long
- void sherry()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- int main()
- {
- sherry();
- ll n, m, count = 0;
- cin >> n >> m;
- ll sum[m + 1]{}, sum2[m + 1]{};
- for (ll i = 1; i <= n; i++)
- {
- ll a, b;
- cin >> a >> b;
- sum[a] += 1;
- sum[b + 1] -= 1;
- }
- for (ll i = 1; i <= m; i++)
- {
- sum2[i] = sum2[i - 1] + sum[i];
- if (sum2[i] == 0)
- count++;
- }
- cout << count << "\n";
- for (ll i = 1; i <= m; i++)
- {
- if (sum2[i] == 0)
- cout << i << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement