Submission #2857012


Source Code Expand

#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


char c[2] = { 'S','W' };

int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int y = 0;y < 2;y++) {
		for (int z = 0;z < 2;z++) {
			string t;
			t += c[y];
			t += c[z];
			for (int i = 1;i < n-1;i++) {
				if (t[i] == 'S'&&t[i - 1] == 'S') {
					if (s[i] == 'o')t+='S';
					else t+= 'W';
				}
				else if (t[i] == 'S'&&t[i - 1] == 'W') {
					if (s[i] == 'o')t+='W';
					else t+='S';
				}
				else if (t[i] == 'W'&&t[i - 1] == 'S') {
					if (s[i] == 'o')t+='W';
					else t+= 'S';
				}
				else {
					if (s[i] == 'o')t += 'S';
					else t+= 'W';
				}
			}
			bool fl = 0;
			if (t[n - 1] == 'S') {
				if (s[n - 1] == 'o') {
					if (t[n - 2] == t[0])fl = 1;
				}
				else {
					if (t[n - 2] != t[0])fl = 1;
				}
			}
			else {
				if (s[n - 1] == 'o') {
					if (t[n - 2] != t[0])fl = 1;
				}
				else {
					if (t[n - 2] == t[0])fl = 1;
				}
			}

			if (fl) {
				if (t[0] == 'S') {
					if (s[0] == 'o') {
						if (t[n - 1] == t[1]) {
							cout << t << endl;
							return 0;
						}
					}
					else {
						if (t[n - 1] != t[1]) {
							cout << t << endl;
							return 0;
						}
					}
				}
				else {
					if (s[n - 1] == 'o') {
						if (t[n - 2] != t[0]) {
							cout << t << endl;
							return 0;
						}
					}
					else {
						if (t[n - 2] == t[0]) {
							cout << t << endl;
							return 0;
						}
					}
				}
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User kakakakaneko
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2353 Byte
Status WA
Exec Time 10 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 13
WA × 3
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 2 ms 384 KB
01.txt AC 6 ms 512 KB
02.txt AC 3 ms 512 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 8 ms 640 KB
06.txt AC 5 ms 640 KB
07.txt AC 2 ms 256 KB
08.txt AC 2 ms 384 KB
09.txt AC 1 ms 256 KB
10.txt WA 3 ms 384 KB
11.txt WA 10 ms 512 KB
12.txt WA 10 ms 640 KB
13.txt AC 9 ms 640 KB