Submission #1296970

#TimeUsernameProblemLanguageResultExecution timeMemory
1296970nataliaaWorld Map (IOI25_worldmap)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
vector<int> ans;
vector<int> v[41];
void rec(int u, int w) {
    ans.push_back(w);
    for(int i = 0; i < v[w].size(); i++) {
        if(v[w][i]!=u){
            rec(w, v[w][i]);
            ans.push_back(v[w][i]);
        }
    }
}
vector<vector<int>> create_map(int N, int M,
vector<int> A, vector<int> B){
    if(m==0) {
        vector<vector<int>> v1(1, vector<int>(1,1));
        return v1;
    }
    for(int i = 0; i<=40; i++) v[i].clear;
    for(int i = 0; i < M; i++) {
        v[A[i]].push_back(B[i]);
        v[B[i]].push_back(A[i]);
    }
    rec(0, 1);
    int n = ans.size();
     vector<vector<int>> ans1(n, vector<int>(n));
     for(int i = 0; i < ans.size(); i++) {
         for(int j = 0; j < ans.size(); j++){
             ans1[i][j] = ans[j];
         }
     }
     return ans1;
}

Compilation message (stderr)

worldmap.cpp: In function 'std::vector<std::vector<int> > create_map(int, int, std::vector<int>, std::vector<int>)':
worldmap.cpp:16:8: error: 'm' was not declared in this scope
   16 |     if(m==0) {
      |        ^
worldmap.cpp:20:37: error: invalid use of non-static member function 'constexpr void std::vector<_Tp, _Alloc>::clear() [with _Tp = int; _Alloc = std::allocator<int>]'
   20 |     for(int i = 0; i<=40; i++) v[i].clear;
      |                                ~~~~~^~~~~
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from worldmap.cpp:1:
/usr/include/c++/13/bits/stl_vector.h:1605:7: note: declared here
 1605 |       clear() _GLIBCXX_NOEXCEPT
      |       ^~~~~