Submission #1124240

#TimeUsernameProblemLanguageResultExecution timeMemory
1124240nikdSeptember (APIO24_september)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int perdifoglie(int N, int M, vector<int> F, vector<vector<int>> S) { vector<vector<int>> adj(N); for(int i = 1; i<N; i++){ adj[i].push_back(F[i]); adj[F[i]].push_back(i); } vector<int>l(N, INT_MAX); vector<int>r(N, -1); for(int i = 0; i<M; i++){ for(int j = 0; j<N-1; j++){ l[S[i][j]] = min(l[S[i][j]], j); r[S[i][j]] = max(r[S[i][j]], j); } } auto dfs = [&](int v, int p, auto&& dfs) -> void{ for(int u: adj[v]){ if(u==p) continue; dfs(u, v, dfs); if(v != 0 && l[v] <= r[u]){ l[v] = min(l[v], l[u]); r[v] = max(r[v], r[u]); } } return; }; dfs(0, -1, dfs); vector<array<int, 2>> itv(N-1); for(int i = 1; i<N; i++) itv[i-1] = {l[i], r[i]}; sort(itv.begin(), itv.end()); int sol = 1; int curr_l = itv[0][0]; int curr_r = itv[0][1]; for(int i = 1; i<N-1; i++){ if(curr_l <= itv[i][0] && itv[i][0] <= curr_r){ curr_r = max(curr_r, itv[i][1]); } else{ sol++; curr_l = itv[i][0]; curr_r = itv[i][1]; } } return sol; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccxT34az.o: in function `mtbpdhr2zxjo1o4i9oreohsbuzzl4s6u::taskcase()':
grader.cpp:(.text+0x50d): undefined reference to `solve(int, int, std::vector<int, std::allocator<int> >, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
collect2: error: ld returned 1 exit status