Submission #1078216

#TimeUsernameProblemLanguageResultExecution timeMemory
1078216Marco_EscandonSeptember (APIO24_september)C++17
Compilation error
0 ms0 KiB
//#include "september.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
#define x first
#define y second
vector<ll> temp,p;
vector<vector<ll>> G;
ll dfs(ll node)
{
	ll asd=temp[node];
	for(auto i:G[node])
		asd=max(asd,dfs(i));
	p[node]=asd;
	return asd;
}
int solve(int n, int m, std::vector<int> F, std::vector<std::vector<int>> S) {
	G.clear(n+2);temp.clear(n+2);p.clear(n+2);
	G.resize(n+2);temp.resize(n+2);p.resize(n+2);
	for(int i=0; i<S[0].size(); i++)
		temp[S[0][i]]=i;
	for(int i=1; i<n; i++)
		G[F[i]].push_back(i);
	dfs(0);
	ll a=-1,cont=0;
	for(int i=0; i<S[0].size(); i++)
	{
		if(i>a) cont++;
		a=max(p[S[0][i]],a);
	}
	return cont;
}

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:18:13: error: no matching function for call to 'std::vector<std::vector<int> >::clear(int)'
   18 |  G.clear(n+2);temp.clear(n+2);p.clear(n+2);
      |             ^
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 september.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1498:7: note: candidate: 'void std::vector<_Tp, _Alloc>::clear() [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
 1498 |       clear() _GLIBCXX_NOEXCEPT
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1498:7: note:   candidate expects 0 arguments, 1 provided
september.cpp:18:29: error: no matching function for call to 'std::vector<int>::clear(int)'
   18 |  G.clear(n+2);temp.clear(n+2);p.clear(n+2);
      |                             ^
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 september.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1498:7: note: candidate: 'void std::vector<_Tp, _Alloc>::clear() [with _Tp = int; _Alloc = std::allocator<int>]'
 1498 |       clear() _GLIBCXX_NOEXCEPT
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1498:7: note:   candidate expects 0 arguments, 1 provided
september.cpp:18:42: error: no matching function for call to 'std::vector<int>::clear(int)'
   18 |  G.clear(n+2);temp.clear(n+2);p.clear(n+2);
      |                                          ^
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 september.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1498:7: note: candidate: 'void std::vector<_Tp, _Alloc>::clear() [with _Tp = int; _Alloc = std::allocator<int>]'
 1498 |       clear() _GLIBCXX_NOEXCEPT
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1498:7: note:   candidate expects 0 arguments, 1 provided
september.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=0; i<S[0].size(); i++)
      |               ~^~~~~~~~~~~~
september.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(int i=0; i<S[0].size(); i++)
      |               ~^~~~~~~~~~~~