Language: C++

#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1e9+7 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

ll n ;
string str ;

bool DFS(string &s,char c){
	s += c ;
	ll sz = s.size() ;
//	cout << s << " " << sz << endl ;
	if(sz<=2){
		if(DFS(s,'S')) return true ;
		else if(DFS(s,'W')) return true ;
		else{
			s.pop_back() ;
			return false ;
		}
	}
	ll p = (sz==n+2?0:sz-2) ;
	if(s.at(p)=='S'){
		if(str.at(p)=='o'&&s.at(sz-3)!=s.at(sz-1)){
			s.pop_back() ;
			return false ;
		}
		if(str.at(p)=='x'&&s.at(sz-3)==s.at(sz-1)){
			s.pop_back() ;
			return false ;
		}
	}else{
		if(str.at(p)=='x'&&s.at(sz-3)!=s.at(sz-1)){
			s.pop_back() ;
			return false ;
		}
		if(str.at(p)=='o'&&s.at(sz-3)==s.at(sz-1)){
			s.pop_back() ;
			return false ;
		}
	}
	if(sz==n){
//		cout << "sz==n" << endl ;
		if(DFS(s,s.at(0))) return true ;
		else{
			s.pop_back() ;
			return false ;
		}
	}
	if(sz==n+1){
//		cout << "sz==n+1" << endl ;
		if(DFS(s,s.at(1))) return true ;
		else{
			s.pop_back() ;
			return false ;
		}
	}
	if(sz==n+2){
//		cout << "sz==n+2" << endl ;
		s.pop_back() ;
		s.pop_back() ;
		cout << s << endl ;
		return true ;
	}
	if(sz<n){
//		cout << "sz<n" << endl ;
		if(DFS(s,'S')) return true ;
		else if(DFS(s,'W')) return true ;
		else{
			s.pop_back() ;
			return false ;
		}
	}
}

int main(){
	cin.tie(nullptr) ;
	ios::sync_with_stdio(false) ;

	cin >> n ;
	cin >> str ;
	if(DFS(""s,'S')) return 0 ;
	if(DFS(""s,'W')) return 0 ;
	cout << -1 << endl ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:110:16: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
  110 |         if(DFS(""s,'S')) return 0 ;
      |                ^~~
a.cc:38:18: note:   initializing argument 1 of 'bool DFS(std::string&, char)'
   38 | bool DFS(string &s,char c){
      |          ~~~~~~~~^
a.cc:111:16: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
  111 |         if(DFS(""s,'W')) return 0 ;
      |                ^~~
a.cc:38:18: note:   initializing argument 1 of 'bool DFS(std::string&, char)'
   38 | bool DFS(string &s,char c){
      |          ~~~~~~~~^
a.cc: In function 'bool DFS(std::string&, char)':
a.cc:102:1: warning: control reaches end of non-void function [-Wreturn-type]
  102 | }
      | ^