Submission #1003380

# Submission time Handle Problem Language Result Execution time Memory
1003380 2024-06-20T09:29:48 Z vjudge1 Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
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;
vi 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(int 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);
        g[b].pb(a);
     }
     dfs(0,-1,0);
     return ans;
}
*//*
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);
        g[b].pb(a);
     }
     
     dfs(0,-1,0);
     return ans;
}

*/


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:4:11: error: request for member 'first' in 'to', which is of non-class type 'int'
    4 | #define f first
      |           ^~~~~
crocodile.cpp:22:15: note: in expansion of macro 'f'
   22 |         if(to.f==p)continue;
      |               ^
crocodile.cpp:5:11: error: request for member 'second' in 'to', which is of non-class type 'int'
    5 | #define s second
      |           ^~~~~~
crocodile.cpp:23:28: note: in expansion of macro 's'
   23 |         dfs(to,from,dis+to.s);
      |                            ^
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:65:24: error: expected '}' before ')' token
   65 |         g[a].pb({b,L[i]);
      |                 ~      ^
crocodile.cpp:65:24: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from crocodile.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
crocodile.cpp:66:25: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   66 |         g[b].pb({a,L[i]});
      |                         ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from crocodile.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~