Submission #1115941


Source Code Expand

#include <bits/stdc++.h>

using namespace std;
#define forn(i, n) for (int i = 0; i < n; i++)
#define re return
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
typedef long long ll;

const ll mod = 1e9 + 7;
ll n;
string s, ans;
void solve() {
	for (int i = 1; i + 1 < n; i++) {
		int k = 0;
		if (s[i] == 'x') k = 1;
		if (ans[i] == 'W') k = 1 - k;
		if (k == 0)
			ans += ans[i - 1];
		else {
			if (ans[i - 1] == 'S')
				ans += 'W';
			else
				ans += 'S';
		}
	}
	//cout << ans<< "\n";
	int k = 0;
	if (s[n - 1] == 'x')
		k = 1;
	if (ans[n - 1] == 'W')
		k = 1 - k;
	if ((k && ans[0] == ans[n - 2]) || (k == 0 && ans[0] != ans[n - 2]))
		re;
	k = 0;
	if (s[0] == 'x') k = 1;
	if (ans[0] == 'W')
		k = 1 - k;
	if ((k && ans[1] == ans[n - 1]) || (k == 0 && ans[1] != ans[n - 1]))
		re;
	cout << ans << "\n";
	exit(0);
}

int main() {
	iostream::sync_with_stdio(0);
	//freopen("a.in", "r", stdin);
	cin >> n >> s;
	ans = "SS";
	solve();
	ans = "SW";
	solve();
	ans = "WS";
	solve();
	ans = "WW";
	solve();
	cout << "-1\n";
}	

Submission Info

Submission Time
Task D - Menagerie
User demon1999
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1105 Byte
Status AC
Exec Time 7 ms
Memory 720 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 16
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 256 KB
00_example_02.txt AC 1 ms 256 KB
00_example_03.txt AC 1 ms 256 KB
01.txt AC 4 ms 512 KB
02.txt AC 2 ms 512 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 5 ms 640 KB
06.txt AC 3 ms 640 KB
07.txt AC 2 ms 384 KB
08.txt AC 2 ms 384 KB
09.txt AC 1 ms 256 KB
10.txt AC 2 ms 384 KB
11.txt AC 7 ms 720 KB
12.txt AC 7 ms 720 KB
13.txt AC 6 ms 720 KB