제출 #489805

#제출 시각아이디문제언어결과실행 시간메모리
489805keta_tsimakuridzeCities (BOI16_cities)C++14
74 / 100
6039 ms239804 KiB
#include<bits/stdc++.h> #define f first #define s second #define pii pair<int,int> #define int long long #define Pii pair<int,pii> using namespace std; const int N = 2e5 + 5, mod = 1e9 + 7, inf = 1e16; // ! int t,n,m,dp[N][35],k; vector<pii> V[N]; priority_queue<Pii, vector<Pii>, greater<Pii> > q; main() { cin >> n >> k >> m; for(int i = 1; i <= n; i++) for(int j = 1; j < (1 << k); j++) dp[i][j] = inf; for(int i = 1; i <= k; i++) { int b; cin >> b; dp[b][1 << (i - 1)] = 0; q.push({0, {b, 1 << (i - 1)}}); } for(int i = 1; i <= m; i++) { int u,v,w; cin >> u >> v >> w; V[u].push_back({v,w}); V[v].push_back({u,w}); } while(q.size()) { int d = q.top().f; int u = q.top().s.f; int t = q.top().s.s; q.pop(); if(d > dp[u][t]) continue; int x = ((1 << k) - 1) ^ t; for(int i = x; ; i = (i - 1) & x) { for(int j = 0; j < V[u].size(); j++) { if(dp[V[u][j].f][t ^ i] > V[u][j].s + d + dp[V[u][j].f][i]) { dp[V[u][j].f][t ^ i] = V[u][j].s + d + dp[V[u][j].f][i]; q.push({V[u][j].s + d + dp[V[u][j].f][i], {V[u][j].f, t ^ i}}); } } if(i == 0) break; } } int ans = inf; for(int i = 1; i <= n; i++) { ans = min(ans, dp[i][(1 << k) - 1]); } cout << ans; }

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

cities.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main() {
      | ^~~~
cities.cpp: In function 'int main()':
cities.cpp:37:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    for(int j = 0; j < V[u].size(); j++) {
      |                   ~~^~~~~~~~~~~~~
#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...