18022022-12-03 19:48:37kdbÁruszállítás üres szakaszaicpp11Wrong answer 2/5032ms11764 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

ostream& operator<<(ostream& os, vector<int>& input)
{
    for (auto i : input)
    {
        os << i << " ";
    }
    os << endl;
    return os;
}

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int>vec(n+1);
    for (size_t i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        vec[a]++;
        vec[b]--;
    }
    for (size_t i = 1; i < n+1; i++)
    {
        vec[i] += vec[i - 1];
    }
    vec[0] = 1;
    vec[n] = 1;
    int c = 0;
    if (vec[1] == 0) c++;
    for (size_t i = 1; i < n + 1; i++)
    {
        if ((vec[i] == 0 && vec[i - 1] != 0) || (vec[i - 1] == 0 && vec[i] != 0))
        {
            c++;
            cout << i - 1 << " " << i << " " << vec[i - 1] << " " << vec[i] << endl;
        }
    }
    cout << (int)c/2 << endl;
    return 0;
}
/*
10 4
8 9
1 6
1 3
3 4
-2
*/
SubtaskSumTestVerdictTimeMemory
base2/50
1Wrong answer0/03ms1828 KiB
2Wrong answer0/032ms9764 KiB
3Wrong answer0/22ms2264 KiB
4Accepted2/22ms2464 KiB
5Wrong answer0/22ms2672 KiB
6Wrong answer0/22ms2740 KiB
7Wrong answer0/22ms2840 KiB
8Wrong answer0/22ms3204 KiB
9Wrong answer0/22ms3340 KiB
10Wrong answer0/22ms3388 KiB
11Wrong answer0/23ms3816 KiB
12Wrong answer0/24ms4168 KiB
13Wrong answer0/39ms4296 KiB
14Wrong answer0/314ms5040 KiB
15Wrong answer0/317ms5020 KiB
16Wrong answer0/326ms11640 KiB
17Wrong answer0/326ms11540 KiB
18Wrong answer0/328ms11444 KiB
19Wrong answer0/310ms6764 KiB
20Wrong answer0/313ms7804 KiB
21Wrong answer0/332ms11764 KiB
22Wrong answer0/330ms11712 KiB