제출 #1343818

#제출 시각아이디문제언어결과실행 시간메모리
1343818vuvietCeste (COCI17_ceste)C++20
0 / 160
1 ms580 KiB
/**
 *     Author:       trviet
 *     Studies at:   Le Hong Phong High School for the Gifted
**/

#include <bits/stdc++.h>

#define ____vuviet__ signed main
#define taskname "COCI17_ceste"

using namespace std;

constexpr int maxn = 2e3 + 3;
constexpr long long inf = 1e18;
long long n, m, d[maxn], mark[maxn];

struct Edge
{
    int u, t, c;
    bool operator < (Edge o) const {
        return 1ll * t * c > 1ll * o.t * o.c;
    }
};

vector<Edge> graph[maxn];

void ReadData()
{
    cin >> n >> m;
    while (m-- > 0)
    {
        int a, b, t, c;
        cin >> a >> b >> t >> c;
        graph[a].push_back({b, t, c});
        graph[b].push_back({a, t, c});
    }
}

void solvebytrvietbels()
{
    ReadData();
    fill(d + 1, d + 1 + n, inf);
    priority_queue<Edge> pq;
    pq.push({1, 0, 0});
    d[1] = 0;
    while (!pq.empty())
    {
        int u = pq.top().u, t = pq.top().t, c = pq.top().c;
        pq.pop();
        if (mark[u]) continue;
        mark[u] = 1, d[u] = min(d[u], 1ll * t * c);
        for (int i = 0; i < graph[u].size(); ++i)
            pq.push({graph[u][i].u, t + graph[u][i].t, c + graph[u][i].c});
    }
    for (int i = 2; i <= n; ++i)
        cout << (d[i] == inf ? -1 : d[i]) << "\n";
}

void freopen_stdio(string speech)
{
    cin.tie(0)->sync_with_stdio(0);
    cerr << speech << "\n";
    if (fopen(taskname ".inp", "r"))
    {
        freopen(taskname ".inp", "r", stdin);
        freopen(taskname ".out", "w", stdout);
    }
}

____vuviet__()
{
    freopen_stdio("...miss you...");
    int t = 1;
    // cin >> t;
    while (t-- > 0)
        solvebytrvietbels();
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

ceste.cpp: In function 'void freopen_stdio(std::string)':
ceste.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen(taskname ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ceste.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen(taskname ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...