Language: C++

#include "bits/stdc++.h"
using namespace std;

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	string x(n,'0');
	
	x[0]='S';
	x[1]='S';
	
	for(int i=1;i<n-1;i++){
		if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
		if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
		if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
		if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
		if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
	}
	
	bool f=false;
	
	if(s[n-1]=='o'){
		if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
		if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
	}else{
		if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
		if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
	}
	
	if(f){
		cout<<x<<endl;
		return 0;
	}
	
	x[0]='S';
	x[1]='W';
	
	for(int i=1;i<n-1;i++){
		if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
		if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
		if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
		if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
		if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
	}
	
	bool f=false;
	
	if(s[n-1]=='o'){
		if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
		if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
	}else{
		if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
		if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
	}
	
	if(f){
		cout<<x<<endl;
		return 0;
	}
	
	x[0]='W';
	x[1]='S';
	
	for(int i=1;i<n-1;i++){
		if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
		if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
		if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
		if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
		if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
	}
	
	bool f=false;
	
	if(s[n-1]=='o'){
		if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
		if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
	}else{
		if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
		if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
	}
	
	if(f){
		cout<<x<<endl;
		return 0;
	}
	
	x[0]='W';
	x[1]='W';
	
	for(int i=1;i<n-1;i++){
		if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='S';
		if(s[i]=='o'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='W';
		if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='W';
		if(s[i]=='o'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='S')x[i+1]='W';
		if(s[i]=='x'&&x[i]=='S'&&x[i-1]=='W')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='S')x[i+1]='S';
		if(s[i]=='x'&&x[i]=='W'&&x[i-1]=='W')x[i+1]='W';
	}
	
	bool f=false;
	
	if(s[n-1]=='o'){
		if(x[n-1]=='S'&&x[n-2]==x[0])f=true;
		if(x[n-1]=='W'&&x[n-2]!=x[0])f=true;
	}else{
		if(x[n-1]=='S'&&x[n-2]!=x[0])f=true;
		if(x[n-1]=='W'&&x[n-2]==x[0])f=true;
	}
	
	if(f){
		cout<<x<<endl;
		return 0;
	}
	
	cout<<-1<<endl;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:14: error: redeclaration of 'bool f'
   55 |         bool f=false;
      |              ^
a.cc:26:14: note: 'bool f' previously declared here
   26 |         bool f=false;
      |              ^
a.cc:84:14: error: redeclaration of 'bool f'
   84 |         bool f=false;
      |              ^
a.cc:26:14: note: 'bool f' previously declared here
   26 |         bool f=false;
      |              ^
a.cc:113:14: error: redeclaration of 'bool f'
  113 |         bool f=false;
      |              ^
a.cc:26:14: note: 'bool f' previously declared here
   26 |         bool f=false;
      |              ^