답안 #920863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920863 2024-02-03T06:44:38 Z Arp 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "crocodile.h"

using i64 = long long;
const i64 inf = 1e18;
const int N = 1e5;
vector<pair<int,int>> adj[N];
bool good[N],vis[N];
i64 dp[N];

void dfs(int u){
  vis[u] = true;
  for(auto [v,w] : adj[u]){
    if(vis[v]) continue;
    dfs(v);
  }
  i64 m1 = inf;
  i64 m2 = inf;
  for(auto [v,w] : adj[u]){
    if(!good[v]) continue;
    i64 T = dp[v] + w;
    if(m1 >= T){
      m2 = m1;
      m1 = T;
    }else if(m2 >= T){
      m2 = T;
    }
  }
  if(m2 != inf){
    good[u] = true;
    dp[u] = m2;
  }
}

int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]){
  for(int i = 0;i<M;i++){
    adj[R[i][0]].emplace_back(R[i][1],L[i]);
    adj[R[i][1]].emplace_back(R[i][0],L[i]);
  }
  for(int i = 0;i<N;i++){
    vis[i] = false;
    good[i] = false;
    dp[i] = inf;
  }
  for(int i = 0;i<K;i++){
    dp[P[i]] = 0;
    good[P[i]] = true;
  }
  dfs(0);
  assert(good[0]);
  return (int) dp[0];
}

Compilation message

crocodile.cpp:7:1: error: 'vector' does not name a type
    7 | vector<pair<int,int>> adj[N];
      | ^~~~~~
crocodile.cpp: In function 'void dfs(int)':
crocodile.cpp:13:20: error: 'adj' was not declared in this scope
   13 |   for(auto [v,w] : adj[u]){
      |                    ^~~
crocodile.cpp:19:20: error: 'adj' was not declared in this scope
   19 |   for(auto [v,w] : adj[u]){
      |                    ^~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:37:5: error: 'adj' was not declared in this scope
   37 |     adj[R[i][0]].emplace_back(R[i][1],L[i]);
      |     ^~~