Submission #23371

# Submission time Handle Problem Language Result Execution time Memory
23371 2017-05-07T07:21:45 Z TAMREF None (KOI16_gas) C++11
100 / 100
763 ms 57588 KB
#include <bits/stdc++.h>
#define fst first
#define snd second
using namespace std;
typedef long long ll;
typedef pair<ll,int> Pair;
typedef pair<ll,pair<int,int> > ppap;
const int MX = 2505;
const ll INF = 1e15;
int V, E, i, j, k=1, x, y, z, tam, ding;
ll D[MX][MX], oil[MX];
vector<Pair> adj[MX];
priority_queue<ppap,vector<ppap>,greater<ppap> > q;
void input(){
    scanf("%d%d",&V,&E);
    for(i=1;i<=V;i++) scanf("%lld",&oil[i]);
    while(E--){
        scanf("%d%d%d",&x,&y,&z);
        adj[x].push_back(make_pair(z,y));
        adj[y].push_back(make_pair(z,x));
    }
    for(i=1;i<=V;i++){
        fill(D[i]+1,D[i]+V+1,INF);
    }
    D[1][1]=0;
}
void dijk(){
    ppap b;
    q.push(make_pair(0,make_pair(1,1)));
    while(!q.empty()){
        b = q.top(); q.pop();
        tam = b.snd.fst, ding=b.snd.snd;
        if(b.fst<=D[tam][ding]){
            for(Pair &p : adj[tam]){
                int koi = oil[p.snd]<oil[ding]?p.snd:ding;
                if(b.fst+oil[ding]*p.fst<D[p.snd][koi]){
                    q.push(make_pair(D[p.snd][koi]=b.fst+oil[ding]*p.fst,make_pair(p.snd,koi)));
                }
            }
        }
    }
}
void output(){
    ll ans = INF;
    for(i=1;i<=V;i++) ans= min(ans,D[V][i]);
    printf("%lld\n",ans);
}
int main(){
    input();
    dijk();
    output();
    return 0;
}

Compilation message

gas.cpp: In function 'void input()':
gas.cpp:15:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&V,&E);
                        ^
gas.cpp:16:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=V;i++) scanf("%lld",&oil[i]);
                                            ^
gas.cpp:18:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&x,&y,&z);
                                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 51124 KB Output is correct
2 Correct 0 ms 51124 KB Output is correct
3 Correct 0 ms 51124 KB Output is correct
4 Correct 0 ms 51124 KB Output is correct
5 Correct 0 ms 51124 KB Output is correct
6 Correct 0 ms 51124 KB Output is correct
7 Correct 0 ms 51124 KB Output is correct
8 Correct 0 ms 51124 KB Output is correct
9 Correct 0 ms 51124 KB Output is correct
10 Correct 0 ms 51124 KB Output is correct
11 Correct 0 ms 51124 KB Output is correct
12 Correct 0 ms 51124 KB Output is correct
13 Correct 0 ms 51124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 51256 KB Output is correct
2 Correct 6 ms 51256 KB Output is correct
3 Correct 16 ms 51256 KB Output is correct
4 Correct 9 ms 51256 KB Output is correct
5 Correct 0 ms 51256 KB Output is correct
6 Correct 6 ms 51256 KB Output is correct
7 Correct 6 ms 51256 KB Output is correct
8 Correct 9 ms 51256 KB Output is correct
9 Correct 6 ms 51256 KB Output is correct
10 Correct 6 ms 51256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 51256 KB Output is correct
2 Correct 3 ms 51388 KB Output is correct
3 Correct 6 ms 51388 KB Output is correct
4 Correct 3 ms 51388 KB Output is correct
5 Correct 6 ms 51388 KB Output is correct
6 Correct 3 ms 51388 KB Output is correct
7 Correct 9 ms 51388 KB Output is correct
8 Correct 9 ms 51388 KB Output is correct
9 Correct 9 ms 51388 KB Output is correct
10 Correct 6 ms 51388 KB Output is correct
11 Correct 6 ms 51388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 51124 KB Output is correct
2 Correct 0 ms 51124 KB Output is correct
3 Correct 0 ms 51124 KB Output is correct
4 Correct 0 ms 51124 KB Output is correct
5 Correct 0 ms 51124 KB Output is correct
6 Correct 0 ms 51124 KB Output is correct
7 Correct 0 ms 51124 KB Output is correct
8 Correct 0 ms 51124 KB Output is correct
9 Correct 0 ms 51124 KB Output is correct
10 Correct 0 ms 51124 KB Output is correct
11 Correct 0 ms 51124 KB Output is correct
12 Correct 0 ms 51124 KB Output is correct
13 Correct 0 ms 51124 KB Output is correct
14 Correct 0 ms 51124 KB Output is correct
15 Correct 0 ms 51124 KB Output is correct
16 Correct 0 ms 51124 KB Output is correct
17 Correct 39 ms 52088 KB Output is correct
18 Correct 46 ms 51704 KB Output is correct
19 Correct 6 ms 51268 KB Output is correct
20 Correct 3 ms 51268 KB Output is correct
21 Correct 3 ms 51268 KB Output is correct
22 Correct 3 ms 51268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 51124 KB Output is correct
2 Correct 0 ms 51124 KB Output is correct
3 Correct 0 ms 51124 KB Output is correct
4 Correct 0 ms 51124 KB Output is correct
5 Correct 0 ms 51124 KB Output is correct
6 Correct 0 ms 51124 KB Output is correct
7 Correct 0 ms 51124 KB Output is correct
8 Correct 0 ms 51124 KB Output is correct
9 Correct 0 ms 51124 KB Output is correct
10 Correct 0 ms 51124 KB Output is correct
11 Correct 0 ms 51124 KB Output is correct
12 Correct 0 ms 51124 KB Output is correct
13 Correct 0 ms 51124 KB Output is correct
14 Correct 3 ms 51256 KB Output is correct
15 Correct 6 ms 51256 KB Output is correct
16 Correct 16 ms 51256 KB Output is correct
17 Correct 9 ms 51256 KB Output is correct
18 Correct 0 ms 51256 KB Output is correct
19 Correct 6 ms 51256 KB Output is correct
20 Correct 6 ms 51256 KB Output is correct
21 Correct 9 ms 51256 KB Output is correct
22 Correct 6 ms 51256 KB Output is correct
23 Correct 6 ms 51256 KB Output is correct
24 Correct 3 ms 51256 KB Output is correct
25 Correct 3 ms 51388 KB Output is correct
26 Correct 6 ms 51388 KB Output is correct
27 Correct 3 ms 51388 KB Output is correct
28 Correct 6 ms 51388 KB Output is correct
29 Correct 3 ms 51388 KB Output is correct
30 Correct 9 ms 51388 KB Output is correct
31 Correct 9 ms 51388 KB Output is correct
32 Correct 9 ms 51388 KB Output is correct
33 Correct 6 ms 51388 KB Output is correct
34 Correct 6 ms 51388 KB Output is correct
35 Correct 0 ms 51124 KB Output is correct
36 Correct 0 ms 51124 KB Output is correct
37 Correct 0 ms 51124 KB Output is correct
38 Correct 39 ms 52088 KB Output is correct
39 Correct 46 ms 51704 KB Output is correct
40 Correct 6 ms 51268 KB Output is correct
41 Correct 3 ms 51268 KB Output is correct
42 Correct 3 ms 51268 KB Output is correct
43 Correct 3 ms 51268 KB Output is correct
44 Correct 13 ms 51256 KB Output is correct
45 Correct 29 ms 51256 KB Output is correct
46 Correct 16 ms 51256 KB Output is correct
47 Correct 763 ms 57588 KB Output is correct
48 Correct 659 ms 57584 KB Output is correct
49 Correct 136 ms 51776 KB Output is correct
50 Correct 66 ms 51520 KB Output is correct
51 Correct 169 ms 51772 KB Output is correct
52 Correct 116 ms 51772 KB Output is correct