Submission #1604038


Source Code Expand

#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
typedef long long ll;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int n;
string s;

int main(){
	cin >> n >> s;
	
	bool tmp[n+2], f=false;
	REP(i,0,4){
		tmp[0]=(i&1); tmp[1]=((i>>1)&1);
		REP(j,1,n){
			if(s[j]=='o'){
				tmp[j+1]=tmp[j]^tmp[j-1];
			}else{
				tmp[j+1]=not(tmp[j]^tmp[j-1]);
			}
		}
		if(tmp[n]==tmp[0]){
			if(s[0]=='o') tmp[n+1]=tmp[n]^tmp[n-1];
			else tmp[n+1]=not(tmp[n]^tmp[n-1]);
			if(tmp[n+1]==tmp[1]){
				f=true;
				break;
			}
		}
	}
	
	if(f) REP(i,0,n) cout << (tmp[i]?'W':'S');
	else cout << -1;
	
	cout << endl;
	return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User ecasdqina
Language C++14 (GCC 5.4.1)
Score 500
Code Size 698 Byte
Status AC
Exec Time 9 ms
Memory 640 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 6 ms 512 KB
02.txt AC 4 ms 384 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 7 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 AC 2 ms 256 KB
11.txt AC 9 ms 640 KB
12.txt AC 9 ms 640 KB
13.txt AC 8 ms 640 KB