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]);
}
}
if (nxor[0]) {
if (line[N-1] == line[1]) {
for(i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
}
else {
if (line[N-1] != line[1]) {
for(i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
}
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]) {
if (line[N-1] == line[1]) {
for(i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
}
else {
if (line[N-1] != line[1]) {
for(i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
}

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]) {
if (line[N-1] == line[1]) {
for(i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
}
else {
if (line[N-1] != line[1]) {
for(i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
}

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]) {
if (line[N-1] == line[1]) {
for(i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
}
else {
if (line[N-1] != line[1]) {
for(i = 0; i < N; i++) {
cout << (!line[i] ? 'S' : 'W');
}
cout << endl;
return 0;
}
}
cout << -1 << endl;
return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'i' was not declared in this scope
   25 | for(i = 0; i < N; i++) {
      |     ^
a.cc:34:5: error: 'i' was not declared in this scope
   34 | for(i = 0; i < N; i++) {
      |     ^
a.cc:45:1: error: array of runtime bound cannot be captured by copy, only by reference
   45 | line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
      | ^~~~
a.cc:45:5: error: expected ',' before '[' token
   45 | line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
      |     ^
      |     ,
a.cc:45:5: error: expected identifier before '[' token
a.cc:45:47: error: expected ']' before ';' token
   45 | line[i] = (nxor[i-1] ? line[i-2] : ~line[i-2]);
      |                                               ^
      |                                               ]
a.cc: In lambda function:
a.cc:45:47: error: expected '{' before ';' token
a.cc: In function 'int main()':
a.cc:47:1: error: 'else' without a previous 'if'
   47 | else {
      | ^~~~
a.cc:48:6: error: 'i' was not declared in this scope
   48 | line[i] = (nxor[i-1] ? ~line[i-2] : line[i-2]);
      |      ^
a.cc: At global scope:
a.cc:51:1: error: expected unqualified-id before 'if'
   51 | if (nxor[0]) {
      | ^~
a.cc:60:1: error: expected unqualified-id before 'else'
   60 | else {
      | ^~~~
a.cc:70:1: error: 'line' does not name a type
   70 | line[0] = -1;
      | ^~~~
a.cc:71:1: error: 'line' does not name a type
   71 | line[1] = 0;
      | ^~~~
a.cc:72:1: error: expected unqualified-id before 'for'
   72 | for (int i = 2; i < N; i++) {
      | ^~~
a.cc:72:17: error: 'i' does not name a type
   72 | for (int i = 2; i < N; i++) {
      |                 ^
a.cc:72:24: error: 'i' does not name a type
   72 | for (int i = 2; i < N; i++) {
      |                        ^
a.cc:76:1: error: expected unqualified-id before 'else'
   76 | else {
      | ^~~~
a.cc:79:1: error: expected declaration before '}' token
   79 | }
      | ^
a.cc:80:1: error: expected unqualified-id before 'if'
   80 | if (nxor[0]) {
      | ^~
a.cc:89:1: error: expected unqualified-id before 'else'
   89 | else {
      | ^~~~
a.cc:99:1: error: 'line' does not name a type
   99 | line[0] = -1;
      | ^~~~
a.cc:100:1: error: 'line' does not name a type
  100 | line[1] = -1;
      | ^~~~
a.cc:101:1: error: expected unqualified-id before 'for'
  101 | for (int i = 2; i < N; i++) {
      | ^~~
a.cc:101:17: error: 'i' does not name a type
  101 | for (int i = 2; i < N; i++) {
      |                 ^
a.cc:101:24: error: 'i' does not name a type
  101 | for (int i = 2; i < N; i++) {
      |                        ^
a.cc:105:1: error: expected unqualified-id before 'else'
  105 | else {
      | ^~~~
a.cc:108:1: error: expected declaration before '}' token
  108 | }
      | ^
a.cc:109:1: error: expected unqualified-id before 'if'
  109 | if (nxor[0]) {
      | ^~
a.cc:118:1: error: expected unqualified-id before 'else'
  118 | else {
      | ^~~~
a.cc:127:1: error: 'cout' does not name a type
  127 | cout << -1 << endl;
      | ^~~~
a.cc:128:1: error: expected unqualified-id before 'return'
  128 | return 0;
      | ^~~~~~
a.cc:130:1: error: expected declaration before '}' token
  130 | }
      | ^