답안 #893365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893365 2023-12-27T03:31:00 Z fdnfksd Airplane (NOI23_airplane) C++14
100 / 100
378 ms 41724 KB
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<ll,ll>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxn=4e5+10;
const ll inf=1e18;
const ll mod=1e9+7;
ll d[3][maxn];
ll n;
vector<ll>g[maxn];
ll a[maxn];
void dij(ll t,ll s)
{
    for(int i=1;i<=n;i++) d[t][i]=inf;
    d[t][s]=0;
    priority_queue<pli,vector<pli>,greater<pli>>pq;
    pq.push({d[t][s],s});
    while(!pq.empty())
    {
        ll u=pq.top().se;
        pq.pop();
        for(int v:g[u])
        {
            if(d[t][v]>max(d[t][u]+1,a[v]))
            {
                d[t][v]=max(d[t][u]+1,a[v]);
                pq.push({d[t][v],v});
            }
        }
    }
}
ll m;
ll ans=inf;
void solve()
{
    cin >> n >> m ;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for(int i=1;i<=m;i++)
    {
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dij(0,1);
    dij(1,n);
    for(int i=1;i<=n;i++)
    {
        if(abs(d[0][i]-d[1][i])<=1) ans=min(ans,d[0][i]+d[1][i]);
    }
    cout << ans;
}
int main()
{
    fastio
    //freopen("c.INP","r",stdin);
    //freopen("c.OUT","w",stdout);
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14680 KB Output is correct
2 Correct 58 ms 28540 KB Output is correct
3 Correct 60 ms 28828 KB Output is correct
4 Correct 60 ms 29012 KB Output is correct
5 Correct 61 ms 29520 KB Output is correct
6 Correct 66 ms 29384 KB Output is correct
7 Correct 79 ms 29608 KB Output is correct
8 Correct 4 ms 14680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14680 KB Output is correct
2 Correct 3 ms 14680 KB Output is correct
3 Correct 4 ms 14684 KB Output is correct
4 Correct 4 ms 14680 KB Output is correct
5 Correct 3 ms 14684 KB Output is correct
6 Correct 4 ms 14940 KB Output is correct
7 Correct 4 ms 14920 KB Output is correct
8 Correct 4 ms 14940 KB Output is correct
9 Correct 4 ms 15092 KB Output is correct
10 Correct 4 ms 14940 KB Output is correct
11 Correct 3 ms 14936 KB Output is correct
12 Correct 4 ms 14940 KB Output is correct
13 Correct 4 ms 14940 KB Output is correct
14 Correct 4 ms 14952 KB Output is correct
15 Correct 5 ms 15056 KB Output is correct
16 Correct 4 ms 15032 KB Output is correct
17 Correct 4 ms 15056 KB Output is correct
18 Correct 3 ms 14692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14680 KB Output is correct
2 Correct 3 ms 14680 KB Output is correct
3 Correct 4 ms 14684 KB Output is correct
4 Correct 4 ms 14680 KB Output is correct
5 Correct 3 ms 14684 KB Output is correct
6 Correct 4 ms 14940 KB Output is correct
7 Correct 4 ms 14920 KB Output is correct
8 Correct 4 ms 14940 KB Output is correct
9 Correct 4 ms 15092 KB Output is correct
10 Correct 4 ms 14940 KB Output is correct
11 Correct 3 ms 14936 KB Output is correct
12 Correct 4 ms 14940 KB Output is correct
13 Correct 4 ms 14940 KB Output is correct
14 Correct 4 ms 14952 KB Output is correct
15 Correct 5 ms 15056 KB Output is correct
16 Correct 4 ms 15032 KB Output is correct
17 Correct 4 ms 15056 KB Output is correct
18 Correct 3 ms 14692 KB Output is correct
19 Correct 5 ms 14844 KB Output is correct
20 Correct 5 ms 14944 KB Output is correct
21 Correct 4 ms 14772 KB Output is correct
22 Correct 4 ms 14840 KB Output is correct
23 Correct 4 ms 14788 KB Output is correct
24 Correct 4 ms 14944 KB Output is correct
25 Correct 4 ms 14940 KB Output is correct
26 Correct 4 ms 14940 KB Output is correct
27 Correct 4 ms 14944 KB Output is correct
28 Correct 4 ms 14988 KB Output is correct
29 Correct 6 ms 14944 KB Output is correct
30 Correct 4 ms 14932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14680 KB Output is correct
2 Correct 58 ms 28540 KB Output is correct
3 Correct 60 ms 28828 KB Output is correct
4 Correct 60 ms 29012 KB Output is correct
5 Correct 61 ms 29520 KB Output is correct
6 Correct 66 ms 29384 KB Output is correct
7 Correct 79 ms 29608 KB Output is correct
8 Correct 4 ms 14680 KB Output is correct
9 Correct 3 ms 14680 KB Output is correct
10 Correct 3 ms 14680 KB Output is correct
11 Correct 4 ms 14684 KB Output is correct
12 Correct 4 ms 14680 KB Output is correct
13 Correct 3 ms 14684 KB Output is correct
14 Correct 4 ms 14940 KB Output is correct
15 Correct 4 ms 14920 KB Output is correct
16 Correct 4 ms 14940 KB Output is correct
17 Correct 4 ms 15092 KB Output is correct
18 Correct 4 ms 14940 KB Output is correct
19 Correct 3 ms 14936 KB Output is correct
20 Correct 4 ms 14940 KB Output is correct
21 Correct 4 ms 14940 KB Output is correct
22 Correct 4 ms 14952 KB Output is correct
23 Correct 5 ms 15056 KB Output is correct
24 Correct 4 ms 15032 KB Output is correct
25 Correct 4 ms 15056 KB Output is correct
26 Correct 3 ms 14692 KB Output is correct
27 Correct 5 ms 14844 KB Output is correct
28 Correct 5 ms 14944 KB Output is correct
29 Correct 4 ms 14772 KB Output is correct
30 Correct 4 ms 14840 KB Output is correct
31 Correct 4 ms 14788 KB Output is correct
32 Correct 4 ms 14944 KB Output is correct
33 Correct 4 ms 14940 KB Output is correct
34 Correct 4 ms 14940 KB Output is correct
35 Correct 4 ms 14944 KB Output is correct
36 Correct 4 ms 14988 KB Output is correct
37 Correct 6 ms 14944 KB Output is correct
38 Correct 4 ms 14932 KB Output is correct
39 Correct 191 ms 30664 KB Output is correct
40 Correct 121 ms 29628 KB Output is correct
41 Correct 98 ms 29868 KB Output is correct
42 Correct 102 ms 29792 KB Output is correct
43 Correct 111 ms 29776 KB Output is correct
44 Correct 128 ms 29776 KB Output is correct
45 Correct 113 ms 29524 KB Output is correct
46 Correct 142 ms 29900 KB Output is correct
47 Correct 154 ms 29696 KB Output is correct
48 Correct 126 ms 29704 KB Output is correct
49 Correct 196 ms 30684 KB Output is correct
50 Correct 211 ms 30328 KB Output is correct
51 Correct 168 ms 30468 KB Output is correct
52 Correct 267 ms 36536 KB Output is correct
53 Correct 194 ms 35176 KB Output is correct
54 Correct 184 ms 35136 KB Output is correct
55 Correct 234 ms 35360 KB Output is correct
56 Correct 306 ms 40392 KB Output is correct
57 Correct 325 ms 40632 KB Output is correct
58 Correct 309 ms 41648 KB Output is correct
59 Correct 335 ms 41724 KB Output is correct
60 Correct 291 ms 41444 KB Output is correct
61 Correct 318 ms 41192 KB Output is correct
62 Correct 290 ms 40320 KB Output is correct
63 Correct 269 ms 40292 KB Output is correct
64 Correct 345 ms 40368 KB Output is correct
65 Correct 319 ms 40416 KB Output is correct
66 Correct 356 ms 40468 KB Output is correct
67 Correct 378 ms 41600 KB Output is correct