1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = long long ;
5
+
6
+ int N;
7
+ string S;
8
+
9
+ bool solve (vector<char >& ws, char c0, char c1, char c2) {
10
+ ws[0 ] = c1, ws[1 ] = c2, ws[N-1 ] = c0;
11
+ for (int i = 1 ; i < N; ++i) {
12
+ int j = (i - 1 + N) % N, k = (i + 1 ) % N;
13
+ if (S[i] == ' o' ) {
14
+ if (ws[i] == ' S' ) ws[k] = ws[j];
15
+ if (ws[i] == ' W' ) ws[k] = ws[j] == ' S' ? ' W' : ' S' ;
16
+ }
17
+ if (S[i] == ' x' ) {
18
+ if (ws[i] == ' S' ) ws[k] = ws[j] == ' S' ? ' W' : ' S' ;
19
+ if (ws[i] == ' W' ) ws[k] = ws[j];
20
+ }
21
+ }
22
+ bool satisfy = true ;
23
+ for (int i = 0 ; i < N; ++i) {
24
+ int j = (i - 1 + N) % N, k = (i + 1 ) % N;
25
+ if (S[i] == ' o' ) {
26
+ if (ws[i] == ' S' ) satisfy &= (ws[k] == ws[j]);
27
+ if (ws[i] == ' W' ) satisfy &= (ws[k] != ws[j]);
28
+ }
29
+ if (S[i] == ' x' ) {
30
+ if (ws[i] == ' S' ) satisfy &= (ws[k] != ws[j]);
31
+ if (ws[i] == ' W' ) satisfy &= (ws[k] == ws[j]);
32
+ }
33
+ }
34
+ return satisfy;
35
+ }
36
+
37
+ vector<char > solve () {
38
+ vector<char > ws (N, ' ' );
39
+ if (solve (ws, ' W' , ' S' , ' W' )) return ws;
40
+ if (solve (ws, ' S' , ' S' , ' S' )) return ws;
41
+ if (solve (ws, ' W' , ' W' , ' S' )) return ws;
42
+ if (solve (ws, ' S' , ' W' , ' W' )) return ws;
43
+ if (solve (ws, ' W' , ' S' , ' S' )) return ws;
44
+ if (solve (ws, ' S' , ' S' , ' W' )) return ws;
45
+ if (solve (ws, ' S' , ' W' , ' S' )) return ws;
46
+ if (solve (ws, ' W' , ' W' , ' W' )) return ws;
47
+ return {};
48
+ }
49
+
50
+ int main () {
51
+ ios_base::sync_with_stdio (false );
52
+ cin.tie (0 ); cout.tie (0 );
53
+
54
+ cin >> N;
55
+ cin >> S;
56
+ auto ans = solve ();
57
+ cout << (ans.size () == 0 ? " -1" : string (ans.begin (), ans.end ())) << endl;
58
+
59
+ return 0 ;
60
+ }
0 commit comments