답안 #1102383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102383 2024-10-18T03:37:29 Z huyngodzz Airplane (NOI23_airplane) C++14
100 / 100
323 ms 28868 KB
    ///huynhocute123///
#include<bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define pii pair<long long ,long long >
#define piii pair<int,pair<int,int>>
#define pb push_back
#define pi M_PI
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = b; i >= a; --i)
#define ALL(v) v.begin(),v.end()
#define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
#define out(name) if(fopen(name, "w")) freopen(name, "w", stdout);
//random_device rd;
//mt19937 rng(rd());
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
//#define int long long
const int maxN =  4 * 1e5 + 9;
const int  modd = 1e9 + 7;
const int base = 2309;
const long long MAX = 1e16+9;
void minimize(int &u, int v){
    if(v < u) u = v;
}
void maximize(int &u, int v){
    if(v > u) u = v;
}
int n, k, t, m, a[maxN];
long long res;
long long S[maxN], T[maxN];
int l, r;
bool vis[maxN];
vector<int> e[maxN];
priority_queue<pii ,vector<pii> ,greater<pii>>pq;
void dt1(int st){
    for(int i =1;i <= n ;i++){
        S[i] = MAX;
        T[i] = MAX;
    }
    S[1] = 0;
    pq.push({0 , 1});
    while(pq.size()){
        long long  du =pq.top().F , u = pq.top().S;
        pq.pop();
        if(du != S[u])continue;
        for(auto x : e[u]){
            if(S[x] > max(du + 1, a[x]*1LL) ){
                S[x] = max(du + 1, a[x]*1LL);
                pq.push({S[x], x});
            }
        }
    }

}
void dt2(int st){

    T[n] = 0;
    pq.push({0 , n});
    while(pq.size()){
        long long  du =pq.top().F , u = pq.top().S;
        pq.pop();
        if(du != T[u])continue;
        for(auto x : e[u]){
            if(T[x] > max(du + 1, a[x]*1LL) ){
                T[x] = max(du + 1, a[x]*1LL);
                pq.push({T[x], x});
            }
        }
    }

}
void solve(){
    cin >> n >> m;
    for(int i =1;i <= n ;i++)cin>> a[i];
    for(int i= 1;i <= m ;i++){
        cin >> l >> r;
        e[l].pb(r);
        e[r].pb(l);
    }
    dt1(1);
    dt2(n);
    res= MAX;
//    for(int i =1; i <= n ;i++){
//        cout <<i << " " << S[i] << " " << T[i] << '\n';
//    }
    for(int i =1;i <= n ;i++){
        res =min(res, max(S[i] , T[i])*2 );
        for(auto j : e[i])res =min(res,max(T[i] ,S[j])* 2 + 1  );
    }
    cout << res;
}
signed main(){
//    freopen("name.inp","r",stdin);
//    freopen("name.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    inp("task.inp");
    t = 1;
   // cin >> t;
    while( t-- )solve();

}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:13:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:100:5: note: in expansion of macro 'inp'
  100 |     inp("task.inp");
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14928 KB Output is correct
2 Correct 49 ms 23504 KB Output is correct
3 Correct 51 ms 23368 KB Output is correct
4 Correct 53 ms 23496 KB Output is correct
5 Correct 52 ms 23368 KB Output is correct
6 Correct 52 ms 23488 KB Output is correct
7 Correct 55 ms 23484 KB Output is correct
8 Correct 3 ms 14928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14928 KB Output is correct
2 Correct 3 ms 15096 KB Output is correct
3 Correct 2 ms 14940 KB Output is correct
4 Correct 3 ms 14928 KB Output is correct
5 Correct 2 ms 14928 KB Output is correct
6 Correct 4 ms 14928 KB Output is correct
7 Correct 3 ms 14928 KB Output is correct
8 Correct 3 ms 14944 KB Output is correct
9 Correct 3 ms 14928 KB Output is correct
10 Correct 4 ms 14928 KB Output is correct
11 Correct 3 ms 14952 KB Output is correct
12 Correct 3 ms 15076 KB Output is correct
13 Correct 3 ms 14928 KB Output is correct
14 Correct 3 ms 14928 KB Output is correct
15 Correct 4 ms 15036 KB Output is correct
16 Correct 6 ms 14928 KB Output is correct
17 Correct 5 ms 15076 KB Output is correct
18 Correct 3 ms 14928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14928 KB Output is correct
2 Correct 3 ms 15096 KB Output is correct
3 Correct 2 ms 14940 KB Output is correct
4 Correct 3 ms 14928 KB Output is correct
5 Correct 2 ms 14928 KB Output is correct
6 Correct 4 ms 14928 KB Output is correct
7 Correct 3 ms 14928 KB Output is correct
8 Correct 3 ms 14944 KB Output is correct
9 Correct 3 ms 14928 KB Output is correct
10 Correct 4 ms 14928 KB Output is correct
11 Correct 3 ms 14952 KB Output is correct
12 Correct 3 ms 15076 KB Output is correct
13 Correct 3 ms 14928 KB Output is correct
14 Correct 3 ms 14928 KB Output is correct
15 Correct 4 ms 15036 KB Output is correct
16 Correct 6 ms 14928 KB Output is correct
17 Correct 5 ms 15076 KB Output is correct
18 Correct 3 ms 14928 KB Output is correct
19 Correct 3 ms 14928 KB Output is correct
20 Correct 5 ms 14928 KB Output is correct
21 Correct 3 ms 14928 KB Output is correct
22 Correct 3 ms 14928 KB Output is correct
23 Correct 3 ms 14928 KB Output is correct
24 Correct 3 ms 14928 KB Output is correct
25 Correct 3 ms 14928 KB Output is correct
26 Correct 4 ms 14928 KB Output is correct
27 Correct 4 ms 14928 KB Output is correct
28 Correct 4 ms 14928 KB Output is correct
29 Correct 4 ms 14928 KB Output is correct
30 Correct 5 ms 14928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 14928 KB Output is correct
2 Correct 49 ms 23504 KB Output is correct
3 Correct 51 ms 23368 KB Output is correct
4 Correct 53 ms 23496 KB Output is correct
5 Correct 52 ms 23368 KB Output is correct
6 Correct 52 ms 23488 KB Output is correct
7 Correct 55 ms 23484 KB Output is correct
8 Correct 3 ms 14928 KB Output is correct
9 Correct 3 ms 14928 KB Output is correct
10 Correct 3 ms 15096 KB Output is correct
11 Correct 2 ms 14940 KB Output is correct
12 Correct 3 ms 14928 KB Output is correct
13 Correct 2 ms 14928 KB Output is correct
14 Correct 4 ms 14928 KB Output is correct
15 Correct 3 ms 14928 KB Output is correct
16 Correct 3 ms 14944 KB Output is correct
17 Correct 3 ms 14928 KB Output is correct
18 Correct 4 ms 14928 KB Output is correct
19 Correct 3 ms 14952 KB Output is correct
20 Correct 3 ms 15076 KB Output is correct
21 Correct 3 ms 14928 KB Output is correct
22 Correct 3 ms 14928 KB Output is correct
23 Correct 4 ms 15036 KB Output is correct
24 Correct 6 ms 14928 KB Output is correct
25 Correct 5 ms 15076 KB Output is correct
26 Correct 3 ms 14928 KB Output is correct
27 Correct 3 ms 14928 KB Output is correct
28 Correct 5 ms 14928 KB Output is correct
29 Correct 3 ms 14928 KB Output is correct
30 Correct 3 ms 14928 KB Output is correct
31 Correct 3 ms 14928 KB Output is correct
32 Correct 3 ms 14928 KB Output is correct
33 Correct 3 ms 14928 KB Output is correct
34 Correct 4 ms 14928 KB Output is correct
35 Correct 4 ms 14928 KB Output is correct
36 Correct 4 ms 14928 KB Output is correct
37 Correct 4 ms 14928 KB Output is correct
38 Correct 5 ms 14928 KB Output is correct
39 Correct 112 ms 23428 KB Output is correct
40 Correct 73 ms 23520 KB Output is correct
41 Correct 76 ms 23368 KB Output is correct
42 Correct 77 ms 23460 KB Output is correct
43 Correct 75 ms 23576 KB Output is correct
44 Correct 80 ms 23356 KB Output is correct
45 Correct 90 ms 23368 KB Output is correct
46 Correct 85 ms 23452 KB Output is correct
47 Correct 86 ms 23536 KB Output is correct
48 Correct 79 ms 23368 KB Output is correct
49 Correct 114 ms 23624 KB Output is correct
50 Correct 136 ms 23368 KB Output is correct
51 Correct 92 ms 23436 KB Output is correct
52 Correct 160 ms 25280 KB Output is correct
53 Correct 139 ms 25280 KB Output is correct
54 Correct 171 ms 25328 KB Output is correct
55 Correct 208 ms 25280 KB Output is correct
56 Correct 223 ms 28784 KB Output is correct
57 Correct 234 ms 28732 KB Output is correct
58 Correct 323 ms 28804 KB Output is correct
59 Correct 211 ms 28860 KB Output is correct
60 Correct 211 ms 28732 KB Output is correct
61 Correct 215 ms 28764 KB Output is correct
62 Correct 194 ms 28772 KB Output is correct
63 Correct 173 ms 28860 KB Output is correct
64 Correct 180 ms 28868 KB Output is correct
65 Correct 225 ms 28860 KB Output is correct
66 Correct 196 ms 28860 KB Output is correct
67 Correct 194 ms 28648 KB Output is correct