Submission #43597

# Submission time Handle Problem Language Result Execution time Memory
43597 2018-03-18T06:08:36 Z leehosu01 None (KOI16_gas) C++14
100 / 100
332 ms 58476 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;
    ios::sync_with_stdio(0);
    cin.tie(0);
    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:15: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 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 660 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 716 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 2 ms 792 KB Output is correct
10 Correct 2 ms 792 KB Output is correct
11 Correct 2 ms 880 KB Output is correct
12 Correct 2 ms 880 KB Output is correct
13 Correct 2 ms 880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 55788 KB Output is correct
2 Correct 45 ms 55788 KB Output is correct
3 Correct 51 ms 55788 KB Output is correct
4 Correct 54 ms 55916 KB Output is correct
5 Correct 46 ms 55916 KB Output is correct
6 Correct 47 ms 55916 KB Output is correct
7 Correct 45 ms 55916 KB Output is correct
8 Correct 46 ms 55916 KB Output is correct
9 Correct 44 ms 55916 KB Output is correct
10 Correct 42 ms 55916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 55916 KB Output is correct
2 Correct 45 ms 56044 KB Output is correct
3 Correct 44 ms 56044 KB Output is correct
4 Correct 45 ms 56044 KB Output is correct
5 Correct 45 ms 56044 KB Output is correct
6 Correct 46 ms 56044 KB Output is correct
7 Correct 47 ms 56044 KB Output is correct
8 Correct 47 ms 56044 KB Output is correct
9 Correct 43 ms 56044 KB Output is correct
10 Correct 44 ms 56044 KB Output is correct
11 Correct 48 ms 56048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 660 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 716 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 2 ms 792 KB Output is correct
10 Correct 2 ms 792 KB Output is correct
11 Correct 2 ms 880 KB Output is correct
12 Correct 2 ms 880 KB Output is correct
13 Correct 2 ms 880 KB Output is correct
14 Correct 13 ms 56048 KB Output is correct
15 Correct 12 ms 56048 KB Output is correct
16 Correct 13 ms 56048 KB Output is correct
17 Correct 60 ms 56048 KB Output is correct
18 Correct 57 ms 56048 KB Output is correct
19 Correct 21 ms 56048 KB Output is correct
20 Correct 13 ms 56048 KB Output is correct
21 Correct 15 ms 56048 KB Output is correct
22 Correct 13 ms 56048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 660 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 716 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 2 ms 792 KB Output is correct
10 Correct 2 ms 792 KB Output is correct
11 Correct 2 ms 880 KB Output is correct
12 Correct 2 ms 880 KB Output is correct
13 Correct 2 ms 880 KB Output is correct
14 Correct 45 ms 55788 KB Output is correct
15 Correct 45 ms 55788 KB Output is correct
16 Correct 51 ms 55788 KB Output is correct
17 Correct 54 ms 55916 KB Output is correct
18 Correct 46 ms 55916 KB Output is correct
19 Correct 47 ms 55916 KB Output is correct
20 Correct 45 ms 55916 KB Output is correct
21 Correct 46 ms 55916 KB Output is correct
22 Correct 44 ms 55916 KB Output is correct
23 Correct 42 ms 55916 KB Output is correct
24 Correct 44 ms 55916 KB Output is correct
25 Correct 45 ms 56044 KB Output is correct
26 Correct 44 ms 56044 KB Output is correct
27 Correct 45 ms 56044 KB Output is correct
28 Correct 45 ms 56044 KB Output is correct
29 Correct 46 ms 56044 KB Output is correct
30 Correct 47 ms 56044 KB Output is correct
31 Correct 47 ms 56044 KB Output is correct
32 Correct 43 ms 56044 KB Output is correct
33 Correct 44 ms 56044 KB Output is correct
34 Correct 48 ms 56048 KB Output is correct
35 Correct 13 ms 56048 KB Output is correct
36 Correct 12 ms 56048 KB Output is correct
37 Correct 13 ms 56048 KB Output is correct
38 Correct 60 ms 56048 KB Output is correct
39 Correct 57 ms 56048 KB Output is correct
40 Correct 21 ms 56048 KB Output is correct
41 Correct 13 ms 56048 KB Output is correct
42 Correct 15 ms 56048 KB Output is correct
43 Correct 13 ms 56048 KB Output is correct
44 Correct 44 ms 56048 KB Output is correct
45 Correct 43 ms 56048 KB Output is correct
46 Correct 51 ms 56048 KB Output is correct
47 Correct 53 ms 56212 KB Output is correct
48 Correct 53 ms 56212 KB Output is correct
49 Correct 332 ms 58476 KB Output is correct
50 Correct 75 ms 58476 KB Output is correct
51 Correct 265 ms 58476 KB Output is correct
52 Correct 122 ms 58476 KB Output is correct