# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
32132 | 2017-09-27T18:44:38 Z | imaxblue | Cities (BOI16_cities) | C++14 | 4000 ms | 262144 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define x first #define y second #define pii pair<int, int> #define p3i pair<pii, int> #define pll pair<ll, ll> #define p3l pair<pll, ll> #define lseg L, (L+R)/2, N*2+1 #define rseg (L+R)/2+1, R, N*2+2 #define ub upper_bound #define lb lower_bound #define pq priority_queue #define MN 1000000007 #define fox(k, x) for (int k=0; k<x; ++k) #define fox1(k, x) for (int k=1; k<=x; ++k) #define foxr(k, x) for (int k=x-1; k>=0; --k) #define fox1r(k, x) for (int k=x; k>0; --k) #define ms multiset #define flood(x) memset(x, 0x3f3f3f3f, sizeof x) #define drain(x) memset(x, 0, sizeof x) #define rng() (rand() >> 3)*rand() int n, m, k, a, b, c, N, B; ll dis[33][100005], D; vector<pii> v[100005]; pq<pair<pair<ll, int>, int> > q; int main(){ flood(dis); cin >> n >> k >> m; fox(l, k){ cin >> a; q.push(mp(mp(0, 1 << l), a)); } fox(l, m){ cin >> a >> b >> c; v[a].pb(mp(b, c)); v[b].pb(mp(a, c)); } while(!q.empty()){ N=q.top().y; D=-q.top().x.x; B=q.top().x.y; q.pop(); if (dis[B][N]<=D) continue; dis[B][N]=D; //cout << N << ' ' << B << endl; if (B==(1 << k)-1){ cout << D << endl; return 0; } fox(l, (1 << k)){ if (dis[B|l][N]>D+dis[l][N]) q.push(mp(mp(-D-dis[l][N], B|l), N)); } fox(l, v[N].size()){ if (dis[B][v[N][l].x]>D+v[N][l].y) q.push(mp(mp(-D-v[N][l].y, B), v[N][l].x)); } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 30140 KB | Output is correct |
2 | Correct | 6 ms | 30140 KB | Output is correct |
3 | Correct | 6 ms | 30140 KB | Output is correct |
4 | Correct | 9 ms | 30140 KB | Output is correct |
5 | Correct | 3 ms | 30508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1059 ms | 73312 KB | Output is correct |
2 | Correct | 983 ms | 73244 KB | Output is correct |
3 | Correct | 246 ms | 37956 KB | Output is correct |
4 | Correct | 283 ms | 71476 KB | Output is correct |
5 | Correct | 456 ms | 45660 KB | Output is correct |
6 | Correct | 229 ms | 39180 KB | Output is correct |
7 | Correct | 9 ms | 30668 KB | Output is correct |
8 | Correct | 3 ms | 30472 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 32592 KB | Output is correct |
2 | Correct | 16 ms | 32588 KB | Output is correct |
3 | Correct | 6 ms | 30832 KB | Output is correct |
4 | Correct | 9 ms | 31436 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4000 ms | 262144 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Memory limit exceeded | 3509 ms | 262144 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |