답안 #886017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886017 2023-12-11T11:28:59 Z vjudge1 Airplane (NOI23_airplane) C++17
0 / 100
101 ms 59272 KB
/* Author : Mychecksdead  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;


int n, m, a[N];
vector<int> g[N], r[N];
bool check(int lim){
  vector<bool> is(n+1);
  for(int i = 1; i <= n; ++i) if(a[i] <= lim) is[i] = 1;
  queue<int> q;
  q.push(1);
  vector<bool> vis(n+1, 0);
  vis[1] = 1;
  while(!q.empty()){
    int v = q.front();
    q.pop();
    for(int u: g[v]){
      if(is[u] && !vis[u]){
        vis[u] = 1;
        q.push(u);
      }
    }
  }
  return vis[n];
}
void solve(){
  cin >> n >> m;
  for(int i = 1; i <= n; ++i) cin >> a[i];
  for(int i = 1; i <= m; ++i){
    int u, v; cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  int l = 0, r = 1e8, ans = 1e8;
  while(l <= r){
    int mid = l+r>>1;
    if(check(mid)) ans = mid, r = mid - 1;
    else l = mid+1;
  }

  cout << 2*ans;
}


int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  solve();
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
  return 0;
} 

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:42:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |     int mid = l+r>>1;
      |               ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 47708 KB Output is correct
2 Incorrect 101 ms 59272 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 47708 KB Output is correct
2 Incorrect 13 ms 47780 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 47708 KB Output is correct
2 Incorrect 13 ms 47780 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 47708 KB Output is correct
2 Incorrect 101 ms 59272 KB Output isn't correct
3 Halted 0 ms 0 KB -