Language: C++

#include <iostream>
#include <string>
using namespace std;

int n;
char s[100001] = {}, a[100001] = {}; // a -> animals; s -> answers
string ans;

bool solve(char x, char y){
	a[1] = x;
	a[2] = y;
	bool a, b;
	for(int i = 2; i <= n-1; i++)
		a[i] == 'S'?
			s[i] == 'o' ? a[i+1] = a[i-1] :
				a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S' :
			s[i] == 'x' ? a[i+1] = a[i-1] :
				a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S';
	a = a[n] == 'S' ?
		s[n] == 'o' ?
			a[n-1] == a[1] ? true : false : 
		a[n-1] != a[1] ? true : false : 
		// a[n] == 'W'
		s[n] == 'o' ?
			a[n-1] == a[1] ? false : true : 
		a[n-1] != a[1] ? false : true ;
	b = a[1] == 'S' ?
		s[1] == 'o' ?
			a[n] == a[2] ? true : false : 
		a[n] != a[2] ? true : false : 
		// a[n] == 'W'
		s[1] == 'o' ?
			a[n] == a[2] ? false : true : 
		a[n] != a[2] ? false : true ;
	return a && b;
	
}

int main() {
	cin >> n;
	for(int h = 1; h <= n; h++) a[h] = '_';
	for(int i = 1; i <= n; i++){
		cin >> s[i];
	}
	
	if(solve('S', 'S')){
		for(int k = 1; k <= n; k++) cout << a[k];
		cout << endl;
	} else if(solve('S', 'W')){
		for(int k = 1; k <= n; k++) cout << a[k];
		cout << endl;
	} else if(solve('W', 'S')){
		for(int k = 1; k <= n; k++) cout << a[k];
		cout << endl;
	} else if(solve('W', 'W')){
		for(int k = 1; k <= n; k++) cout << a[k];
		cout << endl;
	} else cout << "-1" << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'bool solve(char, char)':
a.cc:14:18: error: invalid types 'bool[int]' for array subscript
   14 |                 a[i] == 'S'?
      |                  ^
a.cc:15:40: error: invalid types 'bool[int]' for array subscript
   15 |                         s[i] == 'o' ? a[i+1] = a[i-1] :
      |                                        ^
a.cc:15:49: error: invalid types 'bool[int]' for array subscript
   15 |                         s[i] == 'o' ? a[i+1] = a[i-1] :
      |                                                 ^
a.cc:16:34: error: invalid types 'bool[int]' for array subscript
   16 |                                 a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S' :
      |                                  ^
a.cc:16:50: error: invalid types 'bool[int]' for array subscript
   16 |                                 a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S' :
      |                                                  ^
a.cc:16:65: error: invalid types 'bool[int]' for array subscript
   16 |                                 a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S' :
      |                                                                 ^
a.cc:17:40: error: invalid types 'bool[int]' for array subscript
   17 |                         s[i] == 'x' ? a[i+1] = a[i-1] :
      |                                        ^
a.cc:17:49: error: invalid types 'bool[int]' for array subscript
   17 |                         s[i] == 'x' ? a[i+1] = a[i-1] :
      |                                                 ^
a.cc:18:34: error: invalid types 'bool[int]' for array subscript
   18 |                                 a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S';
      |                                  ^
a.cc:18:50: error: invalid types 'bool[int]' for array subscript
   18 |                                 a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S';
      |                                                  ^
a.cc:18:65: error: invalid types 'bool[int]' for array subscript
   18 |                                 a[i-1] == 'S' ? a[i+1] = 'W' : a[i+1] = 'S';
      |                                                                 ^
a.cc:19:14: error: invalid types 'bool[int]' for array subscript
   19 |         a = a[n] == 'S' ?
      |              ^
a.cc:21:26: error: invalid types 'bool[int]' for array subscript
   21 |                         a[n-1] == a[1] ? true : false :
      |                          ^
a.cc:21:36: error: invalid types 'bool[int]' for array subscript
   21 |                         a[n-1] == a[1] ? true : false :
      |                                    ^
a.cc:22:18: error: invalid types 'bool[int]' for array subscript
   22 |                 a[n-1] != a[1] ? true : false :
      |                  ^
a.cc:22:28: error: invalid types 'bool[int]' for array subscript
   22 |                 a[n-1] != a[1] ? true : false :
      |                            ^
a.cc:25:26: error: invalid types 'bool[int]' for array subscript
   25 |                         a[n-1] == a[1] ? false : true :
      |                          ^
a.cc:25:36: error: invalid types 'bool[int]' for array subscript
   25 |                         a[n-1] == a[1] ? false : true :
      |                                    ^
a.cc:26:18: error: invalid types 'bool[int]' for array subscript
   26 |                 a[n-1] != a[1] ? false : true ;
      |                  ^
a.cc:26:28: error: invalid types 'bool[int]' for array subscript
   26 |                 a[n-1] != a[1] ? false : true ;
      |                            ^
a.cc:27:14: error: invalid types 'bool[int]' for array subscript
   27 |         b = a[1] == 'S' ?
      |              ^
a.cc:29:26: error: invalid types 'bool[int]' for array subscript
   29 |                         a[n] == a[2] ? true : false :
      |                          ^
a.cc:29:34: error: invalid types 'bool[int]' for array subscript
   29 |                         a[n] == a[2] ? true : false :
      |                                  ^
a.cc:30:18: error: invalid types 'bool[int]' for array subscript
   30 |                 a[n] != a[2] ? true : false :
      |                  ^
a.cc:30:26: error: invalid types 'bool[int]' for array subscript
   30 |                 a[n] != a[2] ? true : false :
      |                          ^
a.cc:33:26: error: invalid types 'bool[int]' for array subscript
   33 |                         a[n] == a[2] ? false : true :
      |                          ^
a.cc:33:34: error: invalid types 'bool[int]' for array subscript
   33 |                         a[n] == a[2] ? false : true :
      |                                  ^
a.cc:34:18: error: invalid types 'bool[int]' for array subscript
   34 |                 a[n] != a[2] ? false : true ;
      |                  ^
a.cc:34:26: error: invalid types 'bool[int]' for array subscript
   34 |                 a[n] != a[2] ? false : true ;
      |                          ^