Language: C++

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<char> VB;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const long long INF=(LL)(1e9)*(LL)(1e9);

template<class T>
void chmin(T& a, const T& b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T& b)
{
	if(a<b)
		a=b;
}

const LL pow(const LL p, const LL q)
{
	LL t=1;
	REP(i,q)
		t*=p;
	return t;
}

int vctoi(vector<char> c)
{
	int t=0;
	REP(i,26)
	{
		t+=(1<<i);
	}
	return t;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin>>s;
	int n=s.size();
	vector<vector<char>> let(n+1,vector<char>(26));
	vector<pair<vector<char>,int>> li(n+1);
	vector<char> tlet(26);
	REP(i,n)
	{
		tlet[s[i]-'a']=1-tlet[s[i]-'a'];
		let[i+1]=tlet;
		li[i+1]=pair<int,int>(vctoi(tlet), i+1);
	}
	sort(ALL(li));

	int inf=1e9;
	vector<int> memo(n+1,inf);
	memo[0]=0;
	for(int i=0;i<n;i++)
	{
		vector<char> s=let[i];
		REP(j,27)
		{
			if(j!=26)
				s[j]=1-s[j];
			int si=vctoi(s);
			auto p=lower_bound(ALL(li),pair<int,int>(si,-1));
			while((*p).first==si)
			{
				chmin(memo[(*p).second],memo[i]+1);
				p++;
			}
			if(j!=26)
				s[j]=1-s[j];
		}
	}
	//REP(i,n+1)
	//cout<<memo[i]<<" \n"[i==n];
	cout<<memo[n]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:55: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::vector<char>, int> >, std::pair<std::vector<char>, int> >::value_type' {aka 'std::pair<std::vector<char>, int>'} and 'std::pair<int, int>')
   67 |                 li[i+1]=pair<int,int>(vctoi(tlet), i+1);
      |                                                       ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:946:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U2 = _U1; _T1 = std::vector<char>; _T2 = int]'
  946 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:946:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h: In substitution of 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<std::vector<char, std::allocator<char> >&, const _U1&>, std::is_assignable<int&, const _U2&> >::value, std::pair<std::vector<char>, int>&>::type std::pair<std::vector<char>, int>::operator=(const std::pair<_T1, _T2>&) [with _U1 = int; _U2 = int]':
a.cc:67:41:   required from here
   67 |                 li[i+1]=pair<int,int>(vctoi(tlet), i+1);
      |                                                       ^
/usr/include/c++/14/bits/stl_pair.h:946:9: error: no type named 'type' in 'struct std::enable_if<false, std::pair<std::vector<char>, int>&>'
  946 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:957:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U2 = _U1; _T1 = std::vector<char>; _T2 = int]'
  957 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:957:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h: In substitution of 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<std::vector<char, std::allocator<char> >&, _U1&&>, std::is_assignable<int&, _U2&&> >::value, std::pair<std::vector<char>, int>&>::type std::pair<std::vector<char>, int>::operator=(std::pair<_T1, _T2>&&) [with _U1 = int; _U2 = int]':
a.cc:67:41:   required from here
   67 |                 li[i+1]=pair<int,int>(vctoi(tlet), i+1);
      |                                                       ^
/usr/include/c++/14/bits/stl_pair.h:957:9: error: no type named 'type' in 'struct std::enable_if<false, std::pair<std::vector<char>, int>&>'
  957 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:921:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&>) [with _T1 = std::vector<char>; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&> = const std::pair<std::vector<char>, int>&]'
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:923:65: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::__conditional_t<true, const std::pair<std::vector<char>, int>&, const std::__nonesuch&>' {aka 'const std::pair<std::vector<char>, int>&'}
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  922 |                                        is_copy_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  923 |                                 const pair&, const __nonesuch&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:931:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&>) [with _T1 = std::vector<char>; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&> = std::pair<std::vector<char>, int>&&]'
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:933:55: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::__conditional_t<true, std::pair<std::vector<char>, int>&&, std::__nonesuch&&>' {aka 'std::pair<std::vector<char>, int>&&'}
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  932 |                                        is_move_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  933 |                                 pair&&, __nonesuch&&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:83:41: error: no match for 'operator==' (operand types are 'std::vector<char>' and 'int')
   83 |                         while((*p).first==si)
      |                               ~~~~~~~~~~^~~~
      |                                    |      |
      |                                    |      int
      |                                    std::vector<char>
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181:
/usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
 1103 |     operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note:   template argument deduction/substitution failed:
a.cc:83:43: note:   'std::vector<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   83 |                         while((*p).first==si)
      |                                           ^~
/usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
 1199 |     operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note:   template argument deduction/substitution failed:
a.cc:83:43: note:   'std::vector<char>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
   83 |                         while((*p).first==si)
      |                                           ^~
/usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1274 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note:   template argument deduction/substitution failed:
a.cc:83:43: note:   'std::vector<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   83 |                         while((*p).first==si)
      |                                           ^~
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
 1366 |     operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note:   template argument deduction/substitution failed:
a.cc:83:43: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
   83 |                         while((*p).first==si)
      |                                           ^~
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1441 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note:   template argument deduction/substitution failed:
a.cc:83:43: note:   'std::vector<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   83 |                         while((*p).first==si)
      |                                           ^~
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
 1534 |     operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note:   template argument deduction/substitution failed:
a.cc:83:43: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
   83 |                         while((*p).first==si)
      |                                           ^~
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1613 |     operator==(const sub_match<_Bi_iter>& __lhs,