Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long lont int
vector<vector <int> > g;
vector<int> lol;
int visited[200005],mark[200005],par[200005];
int k;
void dfs(int p,int a)
{
    int i;
    if(visited[a] == 2)
        return;
    if(visited[a] == 1)
    {
        int cur = p;
        mark[cur] = -1;
        while(cur != a)
        {
            cur = par[cur];
            mark[cur] = -1;
        }
        return;
    }
    par[a] = p;
    visited[a] = 1;

    for(auto v : g[a])
    {
        if(v == par[a])
            continue;
        dfs(a,v);
    }
    visited[a] = 2;
}
void dfs2(int a)
{
    if(a == lol[0])
        return;
    else
    {
        visited[a] = 1;
        for(auto v : g[a])
        {
            if(visited[v] != 0)
                continue;
            k--;
            dfs2(v);
        }
    }
}
int main(void)
{
    int n,i;
    cin>>n>>k;
    g.resize(n+1);
    for(i=1;i<=n;i++)
    {
        visited[i] = 0;
        mark[i] = 0;
        int x;
        cin>>x;
        g[x].push_back(i);
        g[i].push_back(x);
    }
    dfs(0,1);
    for(i=1;i<=n;i++)
    {
        visited[i] = 0;
        if(mark[i] == -1)
            lol.push_back(i);
    }
    dfs2(1);
    cout<<lol[k%lol.size()]<<endl;
    return 0;
}


Compiler output:
a.cc:4:19: error: template argument 1 is invalid
    4 | vector<vector <int> > g;
      |                   ^
a.cc:4:19: error: template argument 2 is invalid
a.cc:4:21: error: template argument 1 is invalid
    4 | vector<vector <int> > g;
      |                     ^
a.cc:4:21: error: template argument 2 is invalid
a.cc:5:11: error: template argument 1 is invalid
    5 | vector<int> lol;
      |           ^
a.cc:5:11: error: template argument 2 is invalid
a.cc:3:23: error: expected initializer before 'int'
    3 | #define int long lont int
      |                       ^~~
a.cc:6:1: note: in expansion of macro 'int'
    6 | int visited[200005],mark[200005],par[200005];
      | ^~~
a.cc:3:23: error: expected initializer before 'int'
    3 | #define int long lont int
      |                       ^~~
a.cc:7:1: note: in expansion of macro 'int'
    7 | int k;
      | ^~~
a.cc:3:23: error: expected ',' or '...' before 'int'
    3 | #define int long lont int
      |                       ^~~
a.cc:8:10: note: in expansion of macro 'int'
    8 | void dfs(int p,int a)
      |          ^~~
a.cc: In function 'void dfs(long int)':
a.cc:3:23: error: expected initializer before 'int'
    3 | #define int long lont int
      |                       ^~~
a.cc:10:5: note: in expansion of macro 'int'
   10 |     int i;
      |     ^~~
a.cc:11:8: error: 'visited' was not declared in this scope
   11 |     if(visited[a] == 2)
      |        ^~~~~~~
a.cc:11:16: error: 'a' was not declared in this scope
   11 |     if(visited[a] == 2)
      |                ^
a.cc:13:8: error: 'visited' was not declared in this scope
   13 |     if(visited[a] == 1)
      |        ^~~~~~~
a.cc:13:16: error: 'a' was not declared in this scope
   13 |     if(visited[a] == 1)
      |                ^
a.cc:3:23: error: expected initializer before 'int'
    3 | #define int long lont int
      |                       ^~~
a.cc:15:9: note: in expansion of macro 'int'
   15 |         int cur = p;
      |         ^~~
a.cc:16:9: error: 'mark' was not declared in this scope
   16 |         mark[cur] = -1;
      |         ^~~~
a.cc:16:14: error: 'cur' was not declared in this scope
   16 |         mark[cur] = -1;
      |              ^~~
a.cc:19:19: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   19 |             cur = par[cur];
      |                   ^~~
      |                   __pstl::execution::v1::par
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:24:5: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   24 |     par[a] = p;
      |     ^~~
      |     __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:24:9: error: 'a' was not declared in this scope
   24 |     par[a] = p;
      |         ^
a.cc:24:14: error: 'p' was not declared in this scope
   24 |     par[a] = p;
      |              ^
a.cc:25:5: error: 'visited' was not declared in this scope
   25 |     visited[a] = 1;
      |     ^~~~~~~
a.cc: At global scope:
a.cc:3:23: error: expected ',' or '...' before 'int'
    3 | #define int long lont int
      |                       ^~~
a.cc:35:11: note: in expansion of macro 'int'
   35 | void dfs2(int a)
      |           ^~~
a.cc: In function 'void dfs2(long int)':
a.cc:37:8: error: 'a' was not declared in this scope
   37 |     if(a == lol[0])
      |        ^
a.cc:37:16: error: invalid types 'int[int]' for array subscript
   37 |     if(a == lol[0])
      |                ^
a.cc:41:9: error: 'visited' was not declared in this scope
   41 |         visited[a] = 1;
      |         ^~~~~~~
a.cc:46:13: error: 'k' was not declared in this scope
   46 |             k--;
      |             ^
a.cc: At global scope:
a.cc:3:23: error: expected initializer before 'int'
    3 | #define int long lont int
      |                       ^~~
a.cc:51:1: note: in expansion of macro 'int'
   51 | int main(void)
      | ^~~