Submission #1115958


Source Code Expand

#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
const int SIZE=5+1e6;
const int INF=10+1e9;
const LL p=7+1e9;
bool A[SIZE];
bool ans[SIZE];
LL N;
bool dx[]={0,0,1,1},dy[]={0,1,0,1};
bool issure(bool x[SIZE]){
	REP(i,N){
		if(x[i] == A[i]) if(x[(i+1)%N]!=x[(i-1+N)%N]) return false;
		if(x[i] != A[i]) if(x[(i+1)%N]==x[(i-1+N)%N]) return false;
	}
	return true;
}
int main(){
	cin >> N;
	string s;
	cin >> s;
	REP(i,N){
		A[i]=s[i]=='o';
	}
	bool answer=false;
	REP(i,4){
		ans[0]=dx[i];
		ans[1]=dy[i];
		FOR(j,2,N){
			if(ans[j-1] == A[j-1]) ans[j]=ans[j-2];
			else ans[j]=!ans[j-2];
		}
		if(issure(ans)){
			REP(j,N)
				cout << (ans[j]?'S':'W');
			cout << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Submission Info

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