Language: C++

#include <iostream>
#include <vector>
using namespace std;

vector<vector<int>> c;
vector<int> pre, in;

void post(int id) {
	if (id == -1)
		return;
	post(c[id][0]);
	post(c[id][1]);
	cout << id + 1;
	if (id == pre[0] - 1)
		cout << endl;
	else
		cout << " ";
}

int main()
{
	int n = 0, t = 0;

	cin >> n;

	c.assign(n, {-1, -1});	

	for (int i = 0; i < n; i++) {
		cin >> t;
		pre.push_back(t);
	}

	for (int i = 0; i < n; i++) {
		cin >> t;
		in.push_back(t);
	}

	vector<int>::iterator it1, it2;

	for (int i = 0; i < n - 1; i++) {
		it1 = find(in.begin(), in.end(), pre[i]);
		it2 = find(in.begin(), in.end(), pre[i + 1]);

		if (it1 > it2)
			c[pre[i] - 1][0] = pre[i + 1] - 1;
	}

	for (int i = 0; i < n - 1; i++) {
		it1 = find(pre.begin(), pre.end(), in[i]);
		it2 = find(pre.begin(), pre.end(), in[i + 1]);

		if (it1 < it2)
			c[in[i] - 1][1] = in[i + 1] - 1;
	}

	post(pre[0] - 1);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:27: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   41 |                 it1 = find(in.begin(), in.end(), pre[i]);
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:41:27: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   41 |                 it1 = find(in.begin(), in.end(), pre[i]);
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:42:27: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   42 |                 it2 = find(in.begin(), in.end(), pre[i + 1]);
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:42:27: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   42 |                 it2 = find(in.begin(), in.end(), pre[i + 1]);
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:49:27: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   49 |                 it1 = find(pre.begin(), pre.end(), in[i]);
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:49:27: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   49 |                 it1 = find(pre.begin(), pre.end(), in[i]);
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:50:27: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   50 |                 it2 = find(pre.begin(), pre.end(), in[i + 1]);
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:50:27: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   50 |                 it2 = find(pre.begin(), pre.end(), in[i + 1]);
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~