Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<sstream>
#include<math.h>
#include <iomanip>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1145141919810
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VSUM(vec) std::accumulate(vec.begin(),vec.end(),0LL)
#define LTS(n) to_string(n)
#define STL(str) stoll(str);

using namespace std;

ll n;
string s;

ll prev(ll nn){
	if (nn == 0) return n - 1;
	return nn - 1;
}
ll next(ll nn){
	return (nn + 1) % n;
}

//s_or_w:0->s  s_or_w:1->w
bool fun(ll index,ll s_or_w,VL sum,bool first){
	if(sum[index]==-1) sum[index] = s_or_w;
	else if (!first && sum[index] != -1){
		if (sum[index] == s_or_w){
			if (s_or_w == 0){
				if (s[0] == 'o' && sum[n - 1] == sum[1]){
					rep(i, n) cout << (sum[i] == 0 ? "S" : "W");
					cout << endl;
					return true;
				}
				else if (s[0] == 'x' && sum[n - 1] != sum[1]){
					rep(i, n) cout << (sum[i] == 0 ? "S" : "W");
					cout << endl;
					return true;
				}
				else return false;
			}
			else{
				if (s[0] == 'o' && sum[n - 1] != sum[1]){
					rep(i, n) cout << (sum[i] == 0 ? "S" : "W");
					cout << endl;
					return true;
				}
				else if (sum[0] == 'x' && sum[n - 1] == sum[1]){
					rep(i, n) cout << (sum[i] == 0 ? "S" : "W");
					cout << endl;
					return true;
				}
				else return false;
			}
		}
		else return false;
	}
	if (s_or_w == 0){
		
		if (s[index] == 'o'){
			return fun((index+1)%n, sum[index-1], sum,false);
		}
		else{
			return fun((index + 1)%n, (sum[index - 1] == 0 ? 1 : 0), sum, false);
		}
		
	}
	else{
		
		if (s[index] == 'o'){
			return fun((index + 1)%n, (sum[index - 1] == 0 ? 1 : 0), sum, false);
		}
		else{
			return fun((index + 1)%n, sum[index - 1], sum, false);
		}
		
	}
	return false;
}


int main() {
	cin >> n;
	cin >> s;
	VL sum(n, -1);
	sum[0] = 0; sum[1] = 0;
	if (fun(1, 0, sum, true)) return 0; 
	VL sum(n,-1);
	sum[0] = 1; sum[1] = 0;
	if(fun(1, 1, sum, true)) return 0;
	VL sum(n, -1);
	sum[0] = 1; sum[1] = 1;
	if (fun(1, 0, sum, true)) return 0;
	VL sum(n, -1);
	sum[0] = 0; sum[1] = 1;
	if (fun(1, 1, sum, true)) return 0;
	cout << -1 << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:103:12: error: redeclaration of 'std::vector<long long int> sum'
  103 |         VL sum(n,-1);
      |            ^~~
a.cc:100:12: note: 'std::vector<long long int> sum' previously declared here
  100 |         VL sum(n, -1);
      |            ^~~
a.cc:106:12: error: redeclaration of 'std::vector<long long int> sum'
  106 |         VL sum(n, -1);
      |            ^~~
a.cc:100:12: note: 'std::vector<long long int> sum' previously declared here
  100 |         VL sum(n, -1);
      |            ^~~
a.cc:109:12: error: redeclaration of 'std::vector<long long int> sum'
  109 |         VL sum(n, -1);
      |            ^~~
a.cc:100:12: note: 'std::vector<long long int> sum' previously declared here
  100 |         VL sum(n, -1);
      |            ^~~