제출 #955047

#제출 시각아이디문제언어결과실행 시간메모리
9550473as8사이버랜드 (APIO23_cyberland)C++17
15 / 100
28 ms7000 KiB
#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<bool>& can, 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 && can[i]) { 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<bool> can(N, false); vector<bool> visited(N, false); queue<ll> Q; Q.push(0); visited[0] = true; while(!Q.empty()) { ll node = Q.front(); can[node] = true; Q.pop(); for(auto [el, w] : graph[node]) { if(el == H) continue; if(visited[el]) continue; visited[el] = true; Q.push(el); } } vector<ll> distances(N, LLONG_MAX); dijkstra(graph, can, distances, arr, 0); ll ans = distances[H] == LLONG_MAX ? -1 : distances[H]; return ans; }

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

cyberland.cpp: In function 'void dijkstra(std::vector<std::vector<node> >&, std::vector<bool>&, 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 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...