Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------
int n;
string s;
const bool S=true;
const bool W=false;
bool hoge(vector<bool> &t) {
    int ret=0;
    FOR(i,1,n) {
        if(i!=n-1) {
            if(t[i]==S) {
                if(s[i]=='o') {
                    t.push_back(t[i-1]);
                }
                else {
                    t.push_back(!t[i-1]);
                }
            }
            else {
                if(s[i]=='o') {
                    t.push_back(!t[i-1]);
                }
                else {
                    t.push_back(t[i-1]);
                }
            }
        }
        else {
            if(t[i]==S) {
                if(s[i]=='o') {
                    ret=(t[i-1]==t[0]),;
                }
                else {
                    ret=(t[i-1]!=t[0]);
                }
            }
            else {
                if(s[i]=='o') {
                    ret=(t[i-1]!=t[0]);
                }
                else {
                    ret=([i-1]==t[0]);
                }
            }
        }
    }
    if(t[0]==S) {
        if(s[0]=='o') ret+=(t[n-1]==t[1]);
        else ret+=(t[n-1]!=t[1]);
    }
    else {
        if(s[0]=='o') ret+=(t[n-1]!=t[1]);
        else ret+=([n-1]==t[1]);
    }
    return ret==2;
}
string fuga(vector<bool> a) {
    string ret="";
    for(bool x:a) {
        if(x==S) ret+="S";
        else ret+="W";
    }
    return ret;
}
signed main() {
    cin>>n>>s;
    vector<bool> a={S,S},b={S,W},c={W,S},d={W,W};
    /* */ if(hoge(a)) cout<<fuga(a)<<endl;
    else if(hoge(b)) cout<<fuga(b)<<endl;
    else if(hoge(c)) cout<<fuga(c)<<endl;
    else if(hoge(d)) cout<<fuga(d)<<endl;
    else cout<<-1<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'bool hoge(std::vector<bool>&)':
a.cc:67:40: error: expected primary-expression before ';' token
   67 |                     ret=(t[i-1]==t[0]),;
      |                                        ^
a.cc:78:28: error: expected ',' before '-' token
   78 |                     ret=([i-1]==t[0]);
      |                            ^
      |                            ,
a.cc:78:28: error: expected identifier before '-' token
a.cc: In lambda function:
a.cc:78:31: error: expected '{' before '==' token
   78 |                     ret=([i-1]==t[0]);
      |                               ^~
a.cc: In function 'bool hoge(std::vector<bool>&)':
a.cc:78:31: error: no match for 'operator==' (operand types are 'hoge(std::vector<bool>&)::<lambda()>' and 'std::vector<bool>::reference')
   78 |                     ret=([i-1]==t[0]);
      |                          ~~~~~^~~~~~
      |                          |         |
      |                          |         std::vector<bool>::reference
      |                          hoge(std::vector<bool>&)::<lambda()>
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
                 from a.cc:1:
/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:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/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:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/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:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/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:78:36: note:   'std::vector<bool>::reference' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/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:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/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:78:36: note:   'std::vector<bool>::reference' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/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,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note:   template argument deduction/substitution failed:
a.cc:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
 2186 |     operator==(const match_results<_Bi_iter, _Alloc>& __m1,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note:   template argument deduction/substitution failed:
a.cc:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
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:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1033 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note:   template argument deduction/substitution failed:
a.cc:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::pair<_T1, _T2>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  441 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note:   template argument deduction/substitution failed:
a.cc:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::reverse_iterator<_Iterator>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  486 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note:   template argument deduction/substitution failed:
a.cc:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::reverse_iterator<_Iterator>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1667 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note:   template argument deduction/substitution failed:
a.cc:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::move_iterator<_IteratorL>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1737 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note:   template argument deduction/substitution failed:
a.cc:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::move_iterator<_IteratorL>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
In file included from /usr/include/c++/14/bits/char_traits.h:42,
                 from /usr/include/c++/14/string:42,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
  192 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note:   template argument deduction/substitution failed:
a.cc:78:36: note:   'hoge(std::vector<bool>&)::<lambda()>' is not derived from 'const std::fpos<_StateT>'
   78 |                     ret=([i-1]==t[0]);
      |                                    ^
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allo