Submission #43596

# Submission time Handle Problem Language Result Execution time Memory
43596 2018-03-18T06:05:08 Z leehosu01 None (KOI16_gas) C++14
100 / 100
342 ms 60236 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct A{ll v,l;}tA;
vector<A>E[2501];
queue<A>Q;//v,l은v정점에 L당l가격으로
bool inQ[2502*2501];
ll pc[2501],n,m,NP[2501][2501],mins=1e16;//NP[I][J]::I번에 L당J가격으로 NP[I][J]비용 쓰면서옴
int main()
{
    int i,mil,a,b,c;
    cin>>n>>m;
    for(i=1;i<=n;fill(NP[i++],NP[i]+2501,-1))cin>>pc[i];
    for(i=1;i<=m;i++){cin>>a>>b>>c;E[a].push_back({b,c});E[b].push_back({a,c});}
    NP[1][pc[1]]=0;
    Q.push({1,pc[1]});

    while(!Q.empty())
    {
        tA=Q.front();Q.pop();inQ[tA.v*2501+tA.l]=0;
        for(A&I:E[tA.v])
        {
            mil=min(pc[tA.v],tA.l);
            if(NP[I.v][mil]==-1||NP[I.v][mil]>NP[tA.v][tA.l]+mil*I.l)
            {
                NP[I.v][mil]=NP[tA.v][tA.l]+mil*I.l;
                if(!inQ[I.v*2501+mil]){Q.push({I.v,mil});inQ[I.v*2501+mil]=1;}
            }
        }
    }
    for(i=0;i<=2500;i++)if(NP[n][i]!=-1)mins=min(mins,NP[n][i]);
    printf("%lld",mins);
}

Compilation message

gas.cpp: In function 'int main()':
gas.cpp:13:44: warning: operation on 'i' may be undefined [-Wsequence-point]
     for(i=1;i<=n;fill(NP[i++],NP[i]+2501,-1))cin>>pc[i];
                                            ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 612 KB Output is correct
3 Correct 2 ms 720 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 2 ms 868 KB Output is correct
6 Correct 2 ms 872 KB Output is correct
7 Correct 2 ms 980 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 2 ms 992 KB Output is correct
10 Correct 2 ms 992 KB Output is correct
11 Correct 2 ms 992 KB Output is correct
12 Correct 2 ms 1000 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 56048 KB Output is correct
2 Correct 49 ms 56112 KB Output is correct
3 Correct 47 ms 56112 KB Output is correct
4 Correct 49 ms 56204 KB Output is correct
5 Correct 47 ms 56244 KB Output is correct
6 Correct 51 ms 56316 KB Output is correct
7 Correct 46 ms 56364 KB Output is correct
8 Correct 46 ms 56432 KB Output is correct
9 Correct 53 ms 56484 KB Output is correct
10 Correct 44 ms 56552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 56604 KB Output is correct
2 Correct 46 ms 56720 KB Output is correct
3 Correct 53 ms 56820 KB Output is correct
4 Correct 48 ms 56924 KB Output is correct
5 Correct 48 ms 57004 KB Output is correct
6 Correct 50 ms 57052 KB Output is correct
7 Correct 46 ms 57112 KB Output is correct
8 Correct 46 ms 57172 KB Output is correct
9 Correct 47 ms 57172 KB Output is correct
10 Correct 49 ms 57172 KB Output is correct
11 Correct 45 ms 57208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 612 KB Output is correct
3 Correct 2 ms 720 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 2 ms 868 KB Output is correct
6 Correct 2 ms 872 KB Output is correct
7 Correct 2 ms 980 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 2 ms 992 KB Output is correct
10 Correct 2 ms 992 KB Output is correct
11 Correct 2 ms 992 KB Output is correct
12 Correct 2 ms 1000 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
14 Correct 10 ms 57208 KB Output is correct
15 Correct 10 ms 57208 KB Output is correct
16 Correct 10 ms 57208 KB Output is correct
17 Correct 46 ms 57208 KB Output is correct
18 Correct 54 ms 57208 KB Output is correct
19 Correct 18 ms 57208 KB Output is correct
20 Correct 15 ms 57208 KB Output is correct
21 Correct 17 ms 57208 KB Output is correct
22 Correct 11 ms 57208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 612 KB Output is correct
3 Correct 2 ms 720 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 2 ms 868 KB Output is correct
6 Correct 2 ms 872 KB Output is correct
7 Correct 2 ms 980 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 2 ms 992 KB Output is correct
10 Correct 2 ms 992 KB Output is correct
11 Correct 2 ms 992 KB Output is correct
12 Correct 2 ms 1000 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
14 Correct 46 ms 56048 KB Output is correct
15 Correct 49 ms 56112 KB Output is correct
16 Correct 47 ms 56112 KB Output is correct
17 Correct 49 ms 56204 KB Output is correct
18 Correct 47 ms 56244 KB Output is correct
19 Correct 51 ms 56316 KB Output is correct
20 Correct 46 ms 56364 KB Output is correct
21 Correct 46 ms 56432 KB Output is correct
22 Correct 53 ms 56484 KB Output is correct
23 Correct 44 ms 56552 KB Output is correct
24 Correct 46 ms 56604 KB Output is correct
25 Correct 46 ms 56720 KB Output is correct
26 Correct 53 ms 56820 KB Output is correct
27 Correct 48 ms 56924 KB Output is correct
28 Correct 48 ms 57004 KB Output is correct
29 Correct 50 ms 57052 KB Output is correct
30 Correct 46 ms 57112 KB Output is correct
31 Correct 46 ms 57172 KB Output is correct
32 Correct 47 ms 57172 KB Output is correct
33 Correct 49 ms 57172 KB Output is correct
34 Correct 45 ms 57208 KB Output is correct
35 Correct 10 ms 57208 KB Output is correct
36 Correct 10 ms 57208 KB Output is correct
37 Correct 10 ms 57208 KB Output is correct
38 Correct 46 ms 57208 KB Output is correct
39 Correct 54 ms 57208 KB Output is correct
40 Correct 18 ms 57208 KB Output is correct
41 Correct 15 ms 57208 KB Output is correct
42 Correct 17 ms 57208 KB Output is correct
43 Correct 11 ms 57208 KB Output is correct
44 Correct 46 ms 57392 KB Output is correct
45 Correct 47 ms 57396 KB Output is correct
46 Correct 46 ms 57488 KB Output is correct
47 Correct 72 ms 57844 KB Output is correct
48 Correct 60 ms 57860 KB Output is correct
49 Correct 342 ms 60188 KB Output is correct
50 Correct 75 ms 60188 KB Output is correct
51 Correct 273 ms 60236 KB Output is correct
52 Correct 128 ms 60236 KB Output is correct