Submission #1337807


Source Code Expand

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	string str;
	cin >> N >> str;
	vector<bool> SW(N);//T狼,F羊
	for(int i=0;i<4;++i){
		SW[0] = (i & 1)?true:false;
		SW[1] = (i & 2)?true:false;
		/*
		狼とxを数えて、
		偶数なら羊、奇数なら狼
		*/
		for(int j=0;j<N-2;++j){
			int res = SW[j] + SW[(j+1)];
			if( str[(j+1)] == 'x' ){
				++res;
			}
			if( res & 1 ){
				SW[j+2] = true;
			}else{
				SW[j+2] = false;
			}
		}
		int res;
		bool flag = true;
		{
			res = SW[N-2]+SW[N-1];
			if( str[N-1] == 'x' ){
				++res;
			}
			if( res & 1 ){
				//true;
				if( SW[0] != true ){
					flag = false;
				}
			}else{
				if( SW[0] != false ){
					flag = false;
				}
			}
			if( flag == false ) continue;
		}
		{
			res = SW[N-1]+SW[0];
			if( str[0] == 'x' ){
				++res;
			}
			if( res & 1 ){
				//true;
				if( SW[1] != true ){
					flag = false;
				}
			}else{
				if( SW[1] != false ){
					flag = false;
				}
			}
			if( flag == false ) continue;
		}
		if( flag ){
			for(int i=0;i<N;++i){
				cout << (SW[i]?'W':'S');
			}cout << endl;
			return;
		}
	}
	cout << -1 << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()

Submission Info

Submission Time
Task D - Menagerie
User akarin55
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2330 Byte
Status AC
Exec Time 7 ms
Memory 592 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 3 ms 384 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 5 ms 512 KB
06.txt AC 4 ms 512 KB
07.txt AC 2 ms 256 KB
08.txt AC 2 ms 256 KB
09.txt AC 1 ms 256 KB
10.txt AC 2 ms 256 KB
11.txt AC 7 ms 592 KB
12.txt AC 7 ms 592 KB
13.txt AC 6 ms 592 KB