Submission #1096650

#TimeUsernameProblemLanguageResultExecution timeMemory
1096650raphaelpTreasure Hunt (CCO24_day1problem1)C++14
25 / 25
2124 ms122424 KiB
#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'; } }

Compilation message (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...