Submission #00110
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #include<bits/stdc++.h> using namespace std; typedef long long int lld; #define INF (1<<24) typedef pair< int , int > P; typedef pair< int ,P> Pi; vector<P> edge[811]; int min_cost[811]; int N,M,S,G; int solve( int cost){ priority_queue<Pi,vector<Pi>,greater<Pi> > que; que.push(Pi(cost,P(0,G))); while (!que.empty()){ Pi p = que.top(); que.pop(); int ncost = p.first; int homo = p.second.first; int now = p.second.second; if (now == S) return homo; for ( int i=0;i<edge[now].size();i++){ P pi = edge[now][i]; int next = pi.first; int nc = pi.second; int add = 0; if (min_cost[next] != -1){ add = (ncost+nc)-min_cost[next]; } que.push(Pi(ncost+nc,P(homo+add,next))); } } } int main(){ cin >> N >> M >> S >> G; for ( int i=0;i<M;i++){ int a,b,c; cin >> a >> b >> c; edge[a].push_back(P(b,c)); edge[b].push_back(P(a,c)); } for ( int i=0;i<811;i++){ min_cost[i] = INF; } priority_queue<P,vector<P>,greater<P> > que; que.push(P(0,S)); min_cost[1] = 0; while (!que.empty()){ P p = que.top(); que.pop(); int cost = p.first; int now = p.second; if (now == G) { int homo = solve(cost); cout << homo << " " << cost << endl; return 0; } if (min_cost[now] < cost) continue ; min_cost[now] = cost; for ( int i=0;i<edge[now].size();i++){ P pi = edge[now][i]; int next = pi.first; int nc = pi.second; que.push(P(cost+nc,next)); } } cout << "Homoed." << endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0008 - Mission : ホモへの堕落を回避せよ |
ユーザー名 | ei1428 |
投稿日時 | 2016-05-14 15:19:08 |
言語 | C++11 |
状態 | Time Limit Exceeded |
得点 | 0 |
ソースコード長 | 1596 Byte |
最大実行時間 | 1000 ms |
最大メモリ使用量 | 396068 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 14 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in1.txt | AC | 16 ms | 604 KB |
1
|
in2.txt | AC | 24 ms | 8632 KB |
1
|
in3.txt | AC | 146 ms | 25504 KB |
1
|
in4.txt | WA | 19 ms | 2344 KB |
1
|
in5.txt | TLE | 1000 ms | 395172 KB |
1
|
in6.txt | TLE | 1000 ms | 395592 KB |
1
|
in7.txt | AC | 17 ms | 1700 KB |
1
|
in8.txt | AC | 102 ms | 50572 KB |
1
|
in9.txt | AC | 14 ms | 500 KB |
1
|
in10.txt | TLE | 1000 ms | 394772 KB |
1
|
in11.txt | TLE | 1000 ms | 198420 KB |
1
|
in12.txt | AC | 146 ms | 51044 KB |
1
|
in13.txt | TLE | 1000 ms | 395156 KB |
1
|
in14.txt | AC | 365 ms | 100612 KB |
1
|
in15.txt | TLE | 1000 ms | 395996 KB |
1
|
in16.txt | TLE | 1000 ms | 395236 KB |
1
|
in17.txt | TLE | 1000 ms | 396068 KB |
1
|
in18.txt | TLE | 1000 ms | 395272 KB |
1
|
in19.txt | AC | 17 ms | 1168 KB |
1
|
in20.txt | AC | 999 ms | 394860 KB |
1
|