이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
vector<int> Tab(N);
for (int i = 0; i < N; i++)
cin >> Tab[i];
vector<vector<pair<int, int>>> AR(N);
for (int i = 0; i < M; i++)
{
int a, b, c;
cin >> a >> b >> c;
a--, b--;
AR[a].push_back({b, c});
AR[b].push_back({a, c});
}
priority_queue<pair<int, int>> PQ;
for (int i = 0; i < N; i++)
PQ.push({Tab[i], i});
vector<int> best(N, -1);
while (!PQ.empty())
{
int x = PQ.top().second, y = PQ.top().first;
PQ.pop();
if (best[x] != -1)
continue;
best[x] = y;
for (int i = 0; i < AR[x].size(); i++)
{
PQ.push({y - AR[x][i].second, AR[x][i].first});
}
}
for (int i = 0; i < N; i++)
{
cout << best[i] << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:30:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for (int i = 0; i < AR[x].size(); i++)
| ~~^~~~~~~~~~~~~~
# | 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... |