25612023-01-17 09:49:26zsebiVillanyautócpp11Wrong answer 1/604ms4460 KiB
// villanyauto.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#include <climits>
#include <algorithm>
#define ll long long
using namespace std;
struct ut
{
    ll hova, hossz;

};
priority_queue<ut>que;
ut akt;
bool operator<(const ut& a, const ut& b)
{
    return a.hossz > b.hossz;
}
struct adat
{
    bool lat = false;
    ll hossz = LLONG_MAX;
    vector < pair<ll, ll>>sz;
};

vector<adat>x;
ll n, m, k, a, b, c;
int main()
{
    cin >> n >> m >> k;
    x.resize(n + 1);

    for (int i = 1; i <= m; ++i)
    {
        cin >> a >> b >> c;
        x[a].sz.push_back({ b,c });

    }
    ll ans = 0;
    que.push({ 1,0 });
    while (!que.empty())
    {
        bool ok = false;
        akt = que.top();
        while (x[akt.hova].lat && !que.empty())
        {
            que.pop();
            if (!que.empty())akt = que.top();
        }
        if (que.empty())break;
        que.pop();
        x[akt.hova].lat = true;
        x[akt.hova].hossz = akt.hossz;
        for (auto& e : x[akt.hova].sz)
        {
            if (!x[e.first].lat && x[e.first].hossz > (akt.hossz + e.second))
            {
                ok = true;
                x[e.first].hossz = akt.hossz + e.second;
                que.push({ e.first , akt.hossz + e.second });
            }
            if (!ok)ans += x[akt.hova].hossz;
        }
    }
    
    cout << ans / k;

    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base1/60
1Accepted0/03ms1744 KiB
2Wrong answer0/03ms2028 KiB
3Wrong answer0/12ms2208 KiB
4Wrong answer0/13ms2348 KiB
5Wrong answer0/13ms2564 KiB
6Wrong answer0/22ms2608 KiB
7Wrong answer0/23ms2660 KiB
8Wrong answer0/24ms3036 KiB
9Accepted1/12ms2888 KiB
10Wrong answer0/12ms2924 KiB
11Wrong answer0/12ms2948 KiB
12Wrong answer0/22ms3156 KiB
13Wrong answer0/22ms3356 KiB
14Wrong answer0/22ms3472 KiB
15Wrong answer0/32ms3564 KiB
16Wrong answer0/33ms3668 KiB
17Wrong answer0/22ms3764 KiB
18Wrong answer0/23ms3896 KiB
19Wrong answer0/23ms3860 KiB
20Wrong answer0/23ms3964 KiB
21Wrong answer0/22ms3940 KiB
22Wrong answer0/22ms4088 KiB
23Wrong answer0/32ms3960 KiB
24Wrong answer0/33ms4108 KiB
25Wrong answer0/33ms4368 KiB
26Wrong answer0/34ms4356 KiB
27Wrong answer0/33ms4372 KiB
28Wrong answer0/32ms4460 KiB
29Wrong answer0/32ms4408 KiB
30Wrong answer0/32ms4412 KiB