Submission #879446

#TimeUsernameProblemLanguageResultExecution timeMemory
879446KN200711Cities (BOI16_cities)C++14
14 / 100
297 ms23696 KiB
# include <bits/stdc++.h> # define ll long long # define fi first # define se second using namespace std; vector< pair<int, ll> > edge[100001]; ll dist[100001], mn[100001]; bool vis[100001]; int main() { int N, K, M; scanf("%d %d %d", &N, &K, &M); vector<int> ipr(K); for(int i=0;i<K;i++) { scanf("%d", &ipr[i]); } for(int i=0;i<M;i++) { int a, b; ll c; scanf("%d %d %lld", &a, &b, &c); edge[a].push_back(make_pair(b, c)); edge[b].push_back(make_pair(a, c)); } for(int i=0;i<K;i++) { priority_queue< pair<ll, int> > PQ; PQ.push(make_pair(0ll, ipr[i])); for(int c=1;c<=N;c++) vis[c] = 0; while(!PQ.empty()) { ll a = PQ.top().fi; int b = PQ.top().se; PQ.pop(); if(vis[b]) continue; vis[b] = 1; dist[b] -= a; for(int c=0;c<edge[b].size();c++) { if(!vis[edge[b][c].fi]) PQ.push(make_pair(a - 1ll * edge[b][c].se, edge[b][c].fi)); } } } ll ans = 1e18; for(int d=1;d<=N;d++) { ans = min(ans, dist[d]); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

cities.cpp: In function 'int main()':
cities.cpp:38:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for(int c=0;c<edge[b].size();c++) {
      |                ~^~~~~~~~~~~~~~~
cities.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d %d %d", &N, &K, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
cities.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &ipr[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
cities.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%d %d %lld", &a, &b, &c);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...