이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
#include <bits/stdc++.h>
#include <vector>
#define pll pair<ll, ll>
#define ll long long
using namespace std;
struct node {
ll v, w;
};
void dijkstra(vector<vector<node> >& graph, vector<ll>& distances, vector<int>& t, ll startIndex) {
priority_queue<pll, vector<pll>, greater<> > Q;
distances[startIndex] = 0;
Q.push({0, startIndex});
for(int i = 0; i < graph.size(); i++) {
if(i == startIndex) continue;
if(t[i] == 0) {
distances[i] = 0;
Q.push({0, startIndex});
}
}
while(!Q.empty()) {
ll node = Q.top().second, dist = Q.top().first;
Q.pop();
if(distances[node] < dist) continue;
for(auto [v, w] : graph[node]) {
if(distances[node] + w < distances[v]) {
distances[v] = distances[node] + w;
Q.push({distances[v], v});
}
}
}
}
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
vector<vector<node> > graph(N);
for(int i = 0; i < M; i++) {
graph[x[i]].push_back({y[i], c[i]});
graph[y[i]].push_back({x[i], c[i]});
}
vector<ll> distances(N, LLONG_MAX);
dijkstra(graph, distances, arr, 0);
return distances[H];
}
컴파일 시 표준 에러 (stderr) 메시지
cyberland.cpp: In function 'void dijkstra(std::vector<std::vector<node> >&, std::vector<long long int>&, std::vector<int>&, long long int)':
cyberland.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<node> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int i = 0; i < graph.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... |
# | 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... |