Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
ll dp[210000];
ll to[210000][30];
ll next[30];
bool can[210000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  s='S'+s+'S';
  for(int i=s.size()=1;i>=0;i--){
    for(int j=0;j<26;j++)to[i][j]=next[j];
    if(s[i]!='S')next[str[i]-'a']=i;
  }
  // for(int i=0;i<210000;i++)back[i]=mp(llINF,llINF);

  for(int i=0;i<210000;i++){
    dp[i]=llINF;
  }

  dp[0]=0;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<26;j++){
      dp[to[i][j]]=min(dp[to[i][j]],dp[i]+1);
    }
  }
  can[s.size()-1]=true;
  for(int i=s.size()-1;i>=0;i--)
    for(int j=0;j<26;j++)
      if(dp[to[i][j]]==dp[1]+1 && can[to[i][j]])can[i]=true;
 
  ll now=0;
  while(now != str.size()-1){
    for(int i=0;i<26;i++)
      if(dp[to[now][i]] == dp[now]+1&&can[to[now][i]]){
	cout<<(char)('a'+i);
	now=to[now][i];
	break;
      }
  }
  cout<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:19: error: lvalue required as left operand of assignment
   34 |   for(int i=s.size()=1;i>=0;i--){
      |             ~~~~~~^~
a.cc:35:35: error: reference to 'next' is ambiguous
   35 |     for(int j=0;j<26;j++)to[i][j]=next[j];
      |                                   ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:27:4: note:                 'long long int next [30]'
   27 | ll next[30];
      |    ^~~~
a.cc:36:18: error: reference to 'next' is ambiguous
   36 |     if(s[i]!='S')next[str[i]-'a']=i;
      |                  ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:27:4: note:                 'long long int next [30]'
   27 | ll next[30];
      |    ^~~~
a.cc:36:23: error: 'str' was not declared in this scope; did you mean 'std'?
   36 |     if(s[i]!='S')next[str[i]-'a']=i;
      |                       ^~~
      |                       std
a.cc:56:16: error: 'str' was not declared in this scope; did you mean 'std'?
   56 |   while(now != str.size()-1){
      |                ^~~
      |                std