# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
113705 | 2019-05-28T01:37:18 Z | thebes | Cities (BOI16_cities) | C++14 | 6000 ms | 262144 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 1e5+5; typedef long long ll; typedef pair<ll,ll> pii; struct reeee{ll n, m, d;}; ll n, m, k, i, x, y, w, vs[MN][1<<6], ans = 1LL<<60; vector<pii> adj[MN]; vector<ll> heh; struct pq{bool operator()(const reeee&i,const reeee&j){return i.d>j.d;}}; priority_queue<reeee,vector<reeee>,pq> q; int main(){ for(scanf("%lld%lld%lld",&n,&k,&m),i=1;i<=k;i++){ scanf("%lld",&x); heh.push_back(x); } for(i=1;i<=m;i++){ scanf("%lld%lld%lld",&x,&y,&w); adj[x].push_back({y,w}); adj[y].push_back({x,w}); } memset(vs,0x3f,sizeof(vs)); for(i=0;i<heh.size();i++) q.push({heh[i], 1<<i, 0}); while(q.size()){ auto v = q.top(); q.pop(); if(v.m==(1<<k)-1) ans = min(ans, v.d); if(vs[v.n][v.m]<(1LL<<60)) continue; vs[v.n][v.m] = v.d; for(int mm=0;mm<(1<<k);mm++){ if(v.d+vs[v.n][mm]<vs[v.n][v.m|mm]){ q.push({v.n, v.m|mm, v.d+vs[v.n][mm]}); } } for(auto w : adj[v.n]){ if(v.d+w.second<vs[w.first][v.m]){ q.push({w.first, v.m, v.d+w.second}); } } } printf("%lld\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 52856 KB | Output is correct |
2 | Correct | 41 ms | 52728 KB | Output is correct |
3 | Correct | 40 ms | 52732 KB | Output is correct |
4 | Correct | 41 ms | 52856 KB | Output is correct |
5 | Correct | 41 ms | 53112 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1630 ms | 92236 KB | Output is correct |
2 | Correct | 1629 ms | 91604 KB | Output is correct |
3 | Correct | 756 ms | 72664 KB | Output is correct |
4 | Correct | 790 ms | 114436 KB | Output is correct |
5 | Correct | 610 ms | 73888 KB | Output is correct |
6 | Correct | 346 ms | 89920 KB | Output is correct |
7 | Correct | 48 ms | 53240 KB | Output is correct |
8 | Correct | 42 ms | 53112 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 60 ms | 54536 KB | Output is correct |
2 | Correct | 58 ms | 54516 KB | Output is correct |
3 | Correct | 51 ms | 53784 KB | Output is correct |
4 | Correct | 53 ms | 53752 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 6030 ms | 262144 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4074 ms | 262144 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |