답안 #1003383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003383 2024-06-20T09:30:51 Z vjudge1 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pf push_front
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>

const int MAX = 2001;
vector<pi> g[MAX];
bool is[MAX];
ll ans = 0;
void dfs(int from , int p, ll dis){
 //   cout << from << " " <<dis <<endl;
    if(g[from].size()==1){
         ans = max(ans,dis);
         return;
    }
    for(pi to : g[from]){
        if(to.f==p)continue;
        dfs(to,from,dis+to.s);
    }
    
}



int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
     
     
     for(int i = 0; i< M; i++){
        int a = R[i][0];
        int b = R[i][1];
        g[a].pb({b,L[i]);
        g[b].pb({a,L[i]});
     }
     
     dfs(0,-1,0);
     return ans;
}

Compilation message

crocodile.cpp: In function 'void dfs(int, int, long long int)':
crocodile.cpp:23:13: error: cannot convert 'std::pair<int, int>' to 'int'
   23 |         dfs(to,from,dis+to.s);
      |             ^~
      |             |
      |             std::pair<int, int>
crocodile.cpp:15:14: note:   initializing argument 1 of 'void dfs(int, int, long long int)'
   15 | void dfs(int from , int p, ll dis){
      |          ~~~~^~~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:36:24: error: expected '}' before ')' token
   36 |         g[a].pb({b,L[i]);
      |                 ~      ^