20112022-12-13 22:09:43neszbalÁruszállítás üres szakaszaicpp17Accepted 50/5094ms27828 KiB
#include <iostream>
#include <vector>
using namespace std;

struct abrakadabra{
    int fel,le,adb;
};

int n,m;
vector<abrakadabra>x;

int main()
{
    cin >> n >> m;

    // Use emplace_back to construct elements in place in the vector
    x.resize(n+1);
    for (int i = 1; i <= m; ++i)
    {
        int a, b;
        cin >> a >> b;
        x[a].fel++;
        x[b].le++;
    }

    x[0].adb = 1;
    int db = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (i > 1)
            x[i].adb = x[i-1].adb;
        if (x[i].fel != 0)
            x[i].adb += x[i].fel;
        if (x[i].le != 0)
            x[i].adb -= x[i].le;
        if (x[i].adb == 0 && x[i].adb != x[i-1].adb && i != n)
            db++;
    }

    cout << db;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1876 KiB
2Accepted0/094ms25564 KiB
3Accepted2/22ms2324 KiB
4Accepted2/22ms2532 KiB
5Accepted2/22ms2732 KiB
6Accepted2/22ms2880 KiB
7Accepted2/22ms3092 KiB
8Accepted2/22ms3160 KiB
9Accepted2/22ms3164 KiB
10Accepted2/22ms3168 KiB
11Accepted2/23ms4652 KiB
12Accepted2/23ms5344 KiB
13Accepted3/37ms5556 KiB
14Accepted3/39ms7792 KiB
15Accepted3/38ms7740 KiB
16Accepted3/371ms27364 KiB
17Accepted3/371ms27308 KiB
18Accepted3/379ms27456 KiB
19Accepted3/313ms13508 KiB
20Accepted3/314ms15876 KiB
21Accepted3/387ms27824 KiB
22Accepted3/390ms27828 KiB