# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1104218 |
2024-10-23T09:24:23 Z |
8pete8 |
Airplane (NOI23_airplane) |
C++17 |
|
313 ms |
43164 KB |
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
#define int long long
using namespace std;
const int mod=998244353,mxn=5e5+5,inf=1e18,minf=-1e18,lg=20;
//#undef int
int n,k,m,q;
void setIO(string name){
ios_base::sync_with_stdio(0); cin.tie(0);
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
vector<int>adj[mxn+10];
int val[mxn+10];
vector<int>solve(int st){
vector<int>dist(n+1,inf),last(n+1,-1);
priority_queue<pii,vector<pii>,greater<pii>>pq;
pq.push({0,st});
dist[st]=0;
while(!pq.empty()){
int cur=pq.top().s,cost=pq.top().f;
pq.pop();
if(dist[cur]!=cost||last[cur]==cost)continue;
last[cur]=cost;
for(auto i:adj[cur])if(dist[i]>max(val[i],dist[cur]+1)){
dist[i]=max(val[i],dist[cur]+1);
pq.push({dist[i],i});
}
}
return dist;
}
int32_t main(){
fastio
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>val[i];
for(int i=0;i<m;i++){
int a,b;cin>>a>>b;
adj[a].pb(b);
adj[b].pb(a);
}
vector<int>dist1=solve(1),dist2=solve(n);
int ans=inf;
for(int i=1;i<=n;i++){
ans=min(ans,max(dist1[i],dist2[i])*2);
for(auto j:adj[i])ans=min(ans,max(dist1[i],dist2[j])*2+1);
}
cout<<ans;
}
/*
*/
Compilation message
Main.cpp:32:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
32 | #pragma GCC optimize ("03,unroll-lopps")
| ^
Main.cpp:38:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
38 | void setIO(string name){
| ^
Main.cpp:45:24: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
45 | vector<int>solve(int st){
| ^
Main.cpp:62:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
62 | int32_t main(){
| ^
Main.cpp: In function 'void setIO(std::string)':
Main.cpp:40:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | freopen((name+".in").c_str(),"r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:41:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | freopen((name+".out").c_str(),"w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
13648 KB |
Output is correct |
2 |
Correct |
62 ms |
29672 KB |
Output is correct |
3 |
Correct |
63 ms |
30012 KB |
Output is correct |
4 |
Correct |
64 ms |
29996 KB |
Output is correct |
5 |
Correct |
67 ms |
30448 KB |
Output is correct |
6 |
Correct |
66 ms |
30508 KB |
Output is correct |
7 |
Correct |
66 ms |
30508 KB |
Output is correct |
8 |
Correct |
3 ms |
13648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
13648 KB |
Output is correct |
2 |
Correct |
4 ms |
13648 KB |
Output is correct |
3 |
Correct |
4 ms |
13772 KB |
Output is correct |
4 |
Correct |
4 ms |
13648 KB |
Output is correct |
5 |
Correct |
4 ms |
13648 KB |
Output is correct |
6 |
Correct |
4 ms |
13904 KB |
Output is correct |
7 |
Correct |
4 ms |
14032 KB |
Output is correct |
8 |
Correct |
5 ms |
13904 KB |
Output is correct |
9 |
Correct |
5 ms |
13904 KB |
Output is correct |
10 |
Correct |
4 ms |
13904 KB |
Output is correct |
11 |
Correct |
5 ms |
13904 KB |
Output is correct |
12 |
Correct |
5 ms |
13904 KB |
Output is correct |
13 |
Correct |
7 ms |
13904 KB |
Output is correct |
14 |
Correct |
5 ms |
13904 KB |
Output is correct |
15 |
Correct |
6 ms |
14172 KB |
Output is correct |
16 |
Correct |
5 ms |
14328 KB |
Output is correct |
17 |
Correct |
5 ms |
14160 KB |
Output is correct |
18 |
Correct |
3 ms |
13648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
13648 KB |
Output is correct |
2 |
Correct |
4 ms |
13648 KB |
Output is correct |
3 |
Correct |
4 ms |
13772 KB |
Output is correct |
4 |
Correct |
4 ms |
13648 KB |
Output is correct |
5 |
Correct |
4 ms |
13648 KB |
Output is correct |
6 |
Correct |
4 ms |
13904 KB |
Output is correct |
7 |
Correct |
4 ms |
14032 KB |
Output is correct |
8 |
Correct |
5 ms |
13904 KB |
Output is correct |
9 |
Correct |
5 ms |
13904 KB |
Output is correct |
10 |
Correct |
4 ms |
13904 KB |
Output is correct |
11 |
Correct |
5 ms |
13904 KB |
Output is correct |
12 |
Correct |
5 ms |
13904 KB |
Output is correct |
13 |
Correct |
7 ms |
13904 KB |
Output is correct |
14 |
Correct |
5 ms |
13904 KB |
Output is correct |
15 |
Correct |
6 ms |
14172 KB |
Output is correct |
16 |
Correct |
5 ms |
14328 KB |
Output is correct |
17 |
Correct |
5 ms |
14160 KB |
Output is correct |
18 |
Correct |
3 ms |
13648 KB |
Output is correct |
19 |
Correct |
5 ms |
13904 KB |
Output is correct |
20 |
Correct |
4 ms |
13904 KB |
Output is correct |
21 |
Correct |
5 ms |
13904 KB |
Output is correct |
22 |
Correct |
5 ms |
13904 KB |
Output is correct |
23 |
Correct |
4 ms |
14020 KB |
Output is correct |
24 |
Correct |
4 ms |
13904 KB |
Output is correct |
25 |
Correct |
5 ms |
13948 KB |
Output is correct |
26 |
Correct |
6 ms |
14172 KB |
Output is correct |
27 |
Correct |
5 ms |
13904 KB |
Output is correct |
28 |
Correct |
5 ms |
14160 KB |
Output is correct |
29 |
Correct |
5 ms |
14416 KB |
Output is correct |
30 |
Correct |
6 ms |
14336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
13648 KB |
Output is correct |
2 |
Correct |
62 ms |
29672 KB |
Output is correct |
3 |
Correct |
63 ms |
30012 KB |
Output is correct |
4 |
Correct |
64 ms |
29996 KB |
Output is correct |
5 |
Correct |
67 ms |
30448 KB |
Output is correct |
6 |
Correct |
66 ms |
30508 KB |
Output is correct |
7 |
Correct |
66 ms |
30508 KB |
Output is correct |
8 |
Correct |
3 ms |
13648 KB |
Output is correct |
9 |
Correct |
4 ms |
13648 KB |
Output is correct |
10 |
Correct |
4 ms |
13648 KB |
Output is correct |
11 |
Correct |
4 ms |
13772 KB |
Output is correct |
12 |
Correct |
4 ms |
13648 KB |
Output is correct |
13 |
Correct |
4 ms |
13648 KB |
Output is correct |
14 |
Correct |
4 ms |
13904 KB |
Output is correct |
15 |
Correct |
4 ms |
14032 KB |
Output is correct |
16 |
Correct |
5 ms |
13904 KB |
Output is correct |
17 |
Correct |
5 ms |
13904 KB |
Output is correct |
18 |
Correct |
4 ms |
13904 KB |
Output is correct |
19 |
Correct |
5 ms |
13904 KB |
Output is correct |
20 |
Correct |
5 ms |
13904 KB |
Output is correct |
21 |
Correct |
7 ms |
13904 KB |
Output is correct |
22 |
Correct |
5 ms |
13904 KB |
Output is correct |
23 |
Correct |
6 ms |
14172 KB |
Output is correct |
24 |
Correct |
5 ms |
14328 KB |
Output is correct |
25 |
Correct |
5 ms |
14160 KB |
Output is correct |
26 |
Correct |
3 ms |
13648 KB |
Output is correct |
27 |
Correct |
5 ms |
13904 KB |
Output is correct |
28 |
Correct |
4 ms |
13904 KB |
Output is correct |
29 |
Correct |
5 ms |
13904 KB |
Output is correct |
30 |
Correct |
5 ms |
13904 KB |
Output is correct |
31 |
Correct |
4 ms |
14020 KB |
Output is correct |
32 |
Correct |
4 ms |
13904 KB |
Output is correct |
33 |
Correct |
5 ms |
13948 KB |
Output is correct |
34 |
Correct |
6 ms |
14172 KB |
Output is correct |
35 |
Correct |
5 ms |
13904 KB |
Output is correct |
36 |
Correct |
5 ms |
14160 KB |
Output is correct |
37 |
Correct |
5 ms |
14416 KB |
Output is correct |
38 |
Correct |
6 ms |
14336 KB |
Output is correct |
39 |
Correct |
141 ms |
32044 KB |
Output is correct |
40 |
Correct |
118 ms |
31044 KB |
Output is correct |
41 |
Correct |
126 ms |
31532 KB |
Output is correct |
42 |
Correct |
129 ms |
31276 KB |
Output is correct |
43 |
Correct |
109 ms |
31348 KB |
Output is correct |
44 |
Correct |
102 ms |
31280 KB |
Output is correct |
45 |
Correct |
104 ms |
31276 KB |
Output is correct |
46 |
Correct |
116 ms |
31280 KB |
Output is correct |
47 |
Correct |
116 ms |
31276 KB |
Output is correct |
48 |
Correct |
98 ms |
31304 KB |
Output is correct |
49 |
Correct |
142 ms |
32000 KB |
Output is correct |
50 |
Correct |
121 ms |
31796 KB |
Output is correct |
51 |
Correct |
127 ms |
31800 KB |
Output is correct |
52 |
Correct |
222 ms |
37644 KB |
Output is correct |
53 |
Correct |
171 ms |
36716 KB |
Output is correct |
54 |
Correct |
174 ms |
36840 KB |
Output is correct |
55 |
Correct |
231 ms |
37012 KB |
Output is correct |
56 |
Correct |
258 ms |
42652 KB |
Output is correct |
57 |
Correct |
242 ms |
41940 KB |
Output is correct |
58 |
Correct |
240 ms |
42876 KB |
Output is correct |
59 |
Correct |
256 ms |
42860 KB |
Output is correct |
60 |
Correct |
239 ms |
43164 KB |
Output is correct |
61 |
Correct |
313 ms |
42396 KB |
Output is correct |
62 |
Correct |
286 ms |
41688 KB |
Output is correct |
63 |
Correct |
245 ms |
41884 KB |
Output is correct |
64 |
Correct |
215 ms |
41628 KB |
Output is correct |
65 |
Correct |
258 ms |
41876 KB |
Output is correct |
66 |
Correct |
270 ms |
41884 KB |
Output is correct |
67 |
Correct |
274 ms |
41884 KB |
Output is correct |