답안 #940017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
940017 2024-03-07T03:56:34 Z browntoad Airplane (NOI23_airplane) C++14
32 / 100
1000 ms 24508 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define RREP1(i, n) for(int i = (n); i >= 1; i--)
#define pii pair<int, int>
#define ppp pair<pii, pii>
#define ppi pair<pii, int>
#define pip pair<int, pii>
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#define endl '\n'
#define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)


const ll maxn = 2e5+5;
const ll maxm = 1e4+5;
const ll mod = 1e9+7;
const ll inf = 1ll<<60;

vector<int> g[maxn];
vector<int> h(maxn);
int n, m;

int dis[maxn][2];
void dij(int st, bool typ){
    // source st, typ = 0: it is n
    REP1(i, n) dis[i][typ] = inf;
    priority_queue<pii> pq;

    dis[st][typ] = 0;
    pq.push({0, st});
    while(SZ(pq)){
        pii tp = pq.top(); pq.pop();
        int u = tp.s;
        for(auto v:g[u]){
            if (dis[v][typ] > max(h[v], dis[u][typ]+1)){
                dis[v][typ] = max(h[v], dis[u][typ]+1);
                pq.push({dis[v][typ], v});
            }
        }
    }
}
signed main(){
    IOS();
    cin>>n>>m;
    REP1(i, n) cin>>h[i];
    vector<pii> ee;
    REP(i, m){
        int u, v; cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
        ee.pb({u, v});
    }

    dij(1, 0); dij(n, 1);
    int ans = inf;
    REP1(i, n){
        ans = min(ans, max(dis[i][0], dis[i][1])*2);
    }
    for (auto e:ee){
        int u = e.f, v = e.s;
        ans = min({ans, max(dis[u][0], dis[v][1])*2+1, max(dis[v][0], dis[u][1])*2+1});
    }
    cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 62 ms 22284 KB Output is correct
3 Correct 66 ms 22944 KB Output is correct
4 Correct 64 ms 22848 KB Output is correct
5 Correct 68 ms 23484 KB Output is correct
6 Correct 68 ms 23740 KB Output is correct
7 Correct 68 ms 24508 KB Output is correct
8 Correct 2 ms 7516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 3 ms 7516 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 7516 KB Output is correct
5 Correct 2 ms 7636 KB Output is correct
6 Correct 3 ms 7772 KB Output is correct
7 Correct 4 ms 7772 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 4 ms 7772 KB Output is correct
10 Correct 5 ms 7772 KB Output is correct
11 Correct 5 ms 7648 KB Output is correct
12 Correct 9 ms 7772 KB Output is correct
13 Correct 24 ms 7768 KB Output is correct
14 Correct 84 ms 7772 KB Output is correct
15 Correct 85 ms 7772 KB Output is correct
16 Correct 58 ms 7768 KB Output is correct
17 Correct 60 ms 7772 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 3 ms 7516 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 7516 KB Output is correct
5 Correct 2 ms 7636 KB Output is correct
6 Correct 3 ms 7772 KB Output is correct
7 Correct 4 ms 7772 KB Output is correct
8 Correct 3 ms 7772 KB Output is correct
9 Correct 4 ms 7772 KB Output is correct
10 Correct 5 ms 7772 KB Output is correct
11 Correct 5 ms 7648 KB Output is correct
12 Correct 9 ms 7772 KB Output is correct
13 Correct 24 ms 7768 KB Output is correct
14 Correct 84 ms 7772 KB Output is correct
15 Correct 85 ms 7772 KB Output is correct
16 Correct 58 ms 7768 KB Output is correct
17 Correct 60 ms 7772 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 12 ms 7772 KB Output is correct
20 Correct 3 ms 7772 KB Output is correct
21 Correct 27 ms 7760 KB Output is correct
22 Correct 223 ms 7772 KB Output is correct
23 Correct 14 ms 7772 KB Output is correct
24 Correct 32 ms 7772 KB Output is correct
25 Correct 774 ms 7772 KB Output is correct
26 Correct 359 ms 7772 KB Output is correct
27 Execution timed out 1039 ms 7772 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 62 ms 22284 KB Output is correct
3 Correct 66 ms 22944 KB Output is correct
4 Correct 64 ms 22848 KB Output is correct
5 Correct 68 ms 23484 KB Output is correct
6 Correct 68 ms 23740 KB Output is correct
7 Correct 68 ms 24508 KB Output is correct
8 Correct 2 ms 7516 KB Output is correct
9 Correct 2 ms 7516 KB Output is correct
10 Correct 3 ms 7516 KB Output is correct
11 Correct 2 ms 7516 KB Output is correct
12 Correct 2 ms 7516 KB Output is correct
13 Correct 2 ms 7636 KB Output is correct
14 Correct 3 ms 7772 KB Output is correct
15 Correct 4 ms 7772 KB Output is correct
16 Correct 3 ms 7772 KB Output is correct
17 Correct 4 ms 7772 KB Output is correct
18 Correct 5 ms 7772 KB Output is correct
19 Correct 5 ms 7648 KB Output is correct
20 Correct 9 ms 7772 KB Output is correct
21 Correct 24 ms 7768 KB Output is correct
22 Correct 84 ms 7772 KB Output is correct
23 Correct 85 ms 7772 KB Output is correct
24 Correct 58 ms 7768 KB Output is correct
25 Correct 60 ms 7772 KB Output is correct
26 Correct 2 ms 7516 KB Output is correct
27 Correct 12 ms 7772 KB Output is correct
28 Correct 3 ms 7772 KB Output is correct
29 Correct 27 ms 7760 KB Output is correct
30 Correct 223 ms 7772 KB Output is correct
31 Correct 14 ms 7772 KB Output is correct
32 Correct 32 ms 7772 KB Output is correct
33 Correct 774 ms 7772 KB Output is correct
34 Correct 359 ms 7772 KB Output is correct
35 Execution timed out 1039 ms 7772 KB Time limit exceeded
36 Halted 0 ms 0 KB -