| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1343818 | vuviet | Ceste (COCI17_ceste) | C++20 | 1 ms | 580 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) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
