Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main() {
int N;
string str;
cin >> N >> str;
bool nxor[N];
for (int i = 0; i < N; i++) {
nxor[i] = (str[i] == 'o');
}
int line[N];
line[0] = 0;
line[1] = 0;
for (int i = 2; i < N; i++) {
if (line[i-1] == 0) {
line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
}
else {
line[i] = (nxor[i-1] ? ~line[i-2] : line[i-2]);
}
}
bool c = true;
if (nxor[0] && line[N-1] != line[1]) {
c = false;
}
if (!nxor[0] && line[N-1] == line[1]) {
c = false;
}
if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
 
if (c) {
for(int i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
c = true;
 
line[0] = 0;
line[1] = -1;
for (int i = 2; i < N; i++) {
if (line[i-1] == 0) {
line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
}
else {
line[i] = (nxor[i-1] ? ~line[i-2] : line[i-2]);
}
}
if (nxor[0] && line[N-1] != line[1]) {
c = false;
}
if (!nxor[0] && line[N-1] == line[1]) {
c = false;
}
if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
 
if (c) {
for(int i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
c = true;
 
line[0] = -1;
line[1] = 0;
for (int i = 2; i < N; i++) {
if (line[i-1] == 0) {
line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
}
else {
line[i] = (nxor[i-1] ? ~line[i-2] : line[i-2]);
}
}
 
if (nxor[0] && line[N-1] == line[1]) {
c = false;
}
if (!nxor[0] && line[N-1] != line[1]) {
c = false;
}
if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
 
if (c) {
for(int i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
c = true;
 
line[0] = -1;
line[1] = -1;
for (int i = 2; i < N; i++) {
if (line[i-1] == 0) {
line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
}
else {
line[i] = (nxor[i-1] ? ~line[i-2] : line[i-2]);
}
}
 
if (nxor[0] && line[N-1] == line[1]) {
c = false;
}
if (!nxor[0] && line[N-1] != line[1]) {
c = false;
}
if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
c = false;
}
if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
c = false;
}
 
if (c) {
for(int i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
c = true;
 
cout << -1 << endl;
return 0;
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:14: error: expected ']' before '}' token
   33 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      |              ^
      |              ]
a.cc:33:14: error: expected ')' before '}' token
   33 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      |    ~         ^
      |              )
a.cc:33:14: error: expected primary-expression before '}' token
a.cc: At global scope:
a.cc:33:19: error: expected unqualified-id before '!' token
   33 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      |                   ^
a.cc:36:1: error: expected unqualified-id before 'if'
   36 | if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
      | ^~
a.cc:39:1: error: expected unqualified-id before 'if'
   39 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      | ^~
a.cc:39:13: error: expected declaration before '}' token
   39 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      |             ^
a.cc:39:18: error: expected unqualified-id before '!' token
   39 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      |                  ^
a.cc:43:1: error: expected unqualified-id before 'if'
   43 | if (c) {
      | ^~
a.cc:50:1: error: 'c' does not name a type
   50 | c = true;
      | ^
a.cc:52:1: error: 'line' does not name a type
   52 | line[0] = 0;
      | ^~~~
a.cc:53:1: error: 'line' does not name a type
   53 | line[1] = -1;
      | ^~~~
a.cc:54:1: error: expected unqualified-id before 'for'
   54 | for (int i = 2; i < N; i++) {
      | ^~~
a.cc:54:17: error: 'i' does not name a type
   54 | for (int i = 2; i < N; i++) {
      |                 ^
a.cc:54:24: error: 'i' does not name a type
   54 | for (int i = 2; i < N; i++) {
      |                        ^
a.cc:62:1: error: expected unqualified-id before 'if'
   62 | if (nxor[0] && line[N-1] != line[1]) {
      | ^~
a.cc:65:1: error: expected unqualified-id before 'if'
   65 | if (!nxor[0] && line[N-1] == line[1]) {
      | ^~
a.cc:68:1: error: expected unqualified-id before 'if'
   68 | if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
      | ^~
a.cc:71:1: error: expected unqualified-id before 'if'
   71 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      | ^~
a.cc:71:14: error: expected declaration before '}' token
   71 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      |              ^
a.cc:71:19: error: expected unqualified-id before '!' token
   71 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      |                   ^
a.cc:74:1: error: expected unqualified-id before 'if'
   74 | if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
      | ^~
a.cc:77:1: error: expected unqualified-id before 'if'
   77 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      | ^~
a.cc:77:13: error: expected declaration before '}' token
   77 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      |             ^
a.cc:77:18: error: expected unqualified-id before '!' token
   77 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      |                  ^
a.cc:81:1: error: expected unqualified-id before 'if'
   81 | if (c) {
      | ^~
a.cc:88:1: error: 'c' does not name a type
   88 | c = true;
      | ^
a.cc:90:1: error: 'line' does not name a type
   90 | line[0] = -1;
      | ^~~~
a.cc:91:1: error: 'line' does not name a type
   91 | line[1] = 0;
      | ^~~~
a.cc:92:1: error: expected unqualified-id before 'for'
   92 | for (int i = 2; i < N; i++) {
      | ^~~
a.cc:92:17: error: 'i' does not name a type
   92 | for (int i = 2; i < N; i++) {
      |                 ^
a.cc:92:24: error: 'i' does not name a type
   92 | for (int i = 2; i < N; i++) {
      |                        ^
a.cc:101:1: error: expected unqualified-id before 'if'
  101 | if (nxor[0] && line[N-1] == line[1]) {
      | ^~
a.cc:104:1: error: expected unqualified-id before 'if'
  104 | if (!nxor[0] && line[N-1] != line[1]) {
      | ^~
a.cc:107:1: error: expected unqualified-id before 'if'
  107 | if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
      | ^~
a.cc:110:1: error: expected unqualified-id before 'if'
  110 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      | ^~
a.cc:110:14: error: expected declaration before '}' token
  110 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      |              ^
a.cc:110:19: error: expected unqualified-id before '!' token
  110 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      |                   ^
a.cc:113:1: error: expected unqualified-id before 'if'
  113 | if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
      | ^~
a.cc:116:1: error: expected unqualified-id before 'if'
  116 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      | ^~
a.cc:116:13: error: expected declaration before '}' token
  116 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      |             ^
a.cc:116:18: error: expected unqualified-id before '!' token
  116 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      |                  ^
a.cc:120:1: error: expected unqualified-id before 'if'
  120 | if (c) {
      | ^~
a.cc:127:1: error: 'c' does not name a type
  127 | c = true;
      | ^
a.cc:129:1: error: 'line' does not name a type
  129 | line[0] = -1;
      | ^~~~
a.cc:130:1: error: 'line' does not name a type
  130 | line[1] = -1;
      | ^~~~
a.cc:131:1: error: expected unqualified-id before 'for'
  131 | for (int i = 2; i < N; i++) {
      | ^~~
a.cc:131:17: error: 'i' does not name a type
  131 | for (int i = 2; i < N; i++) {
      |                 ^
a.cc:131:24: error: 'i' does not name a type
  131 | for (int i = 2; i < N; i++) {
      |                        ^
a.cc:140:1: error: expected unqualified-id before 'if'
  140 | if (nxor[0] && line[N-1] == line[1]) {
      | ^~
a.cc:143:1: error: expected unqualified-id before 'if'
  143 | if (!nxor[0] && line[N-1] != line[1]) {
      | ^~
a.cc:146:1: error: expected unqualified-id before 'if'
  146 | if (!line[N-1] && nxor[N-1] && line[N-2] != line[0]) {
      | ^~
a.cc:149:1: error: expected unqualified-id before 'if'
  149 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      | ^~
a.cc:149:14: error: expected declaration before '}' token
  149 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      |              ^
a.cc:149:19: error: expected unqualified-id before '!' token
  149 | if (!line[N-1} && !nxor[N-1] && line[N-2] == line[0]) {
      |                   ^
a.cc:152:1: error: expected unqualified-id before 'if'
  152 | if (line[N-1] && nxor[N-1] && line[N-2] == line[0]) {
      | ^~
a.cc:155:1: error: expected unqualified-id before 'if'
  155 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      | ^~
a.cc:155:13: error: expected declaration before '}' token
  155 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      |             ^
a.cc:155:18: error: expected unqualified-id before '!' token
  155 | if (line[N-1} && !nxor[N-1] && line[N-2] != line[0]) {
      |                  ^
a.cc:159:1: error: expected unqualified-id before 'if'
  159 | if (c) {
      | ^~
a.cc:166:1: error: 'c' does not name a type
  166 | c = true;
      | ^
a.cc:168:1: error: 'cout' does not name a type
  168 | cout << -1 << endl;
      | ^~~~
a.cc:169:1: error: expected unqualified-id before 'return'
  169 | return 0;
      | ^~~~~~
a.cc:171:1: error: expected declaration before '}' token
  171 | }
      | ^