답안 #1024868

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1024868 2024-07-16T11:27:14 Z mindiyak 악어의 지하 도시 (IOI11_crocodile) C++14
0 / 100
2 ms 6744 KB
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<long long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;

#include "crocodile.h"

vector<vpi> paths(1e5+6,vpi());

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  FOR(i,0,M){
    paths[R[i][0]].pb({R[i][1],L[i]});
    paths[R[i][1]].pb({R[i][0],L[i]});
  }

  vi visited(N,0);
  vl dist(N,1e18);

  priority_queue<pi> pq;
  pq.push({0,0});
  dist[0] = 0;

  while(!pq.empty()){
    int node = pq.top().S;pq.pop();
    if(visited[node])continue;
    visited[node] = 1;
    for(auto edge:paths[node]){
      if(dist[edge.F] > dist[node] + edge.S){
        dist[edge.F] = dist[node] + edge.S;
        pq.push({-dist[edge.F],edge.F});
      }
    }
  }

  // FOR(i,0,N){
  //   cout << i << " " << dist[i] << endl;
  // }

  ll ans = 0;
  FOR(i,0,K){
    if(!visited[P[i]])continue;
    ans = max(ans,dist[P[i]]);
  }

  return ans;
}


# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -