Submission #1819195


Source Code Expand

#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int n;
string s;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>n>>s;
	s=s+s[0]+s[1];
	REP(i,4) {
		int prv=i/2,crt=i%2;
		int p[n+2];
		p[0]=prv,p[1]=crt;
		FOR(j,2,n+2) {
			if(s[j-1]=='o') {
				if(p[j-1]==0) p[j]=p[j-2];
				else p[j]=(p[j-2]^1);
			}
			else {
				if(p[j-1]==0) p[j]=(p[j-2]^1);
				else p[j]=p[j-2];
			}
		}
		if(p[0]==p[n]&&p[1]==p[n+1]) {
			REP(j,n) cout<<(p[j]?'W':'S');
			cout<<endl;
			return 0;
		}
	}

	cout<<-1<<endl;

	return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User moko_freedom
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1339 Byte
Status AC
Exec Time 6 ms
Memory 1004 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 768 KB
02.txt AC 3 ms 640 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 5 ms 888 KB
06.txt AC 4 ms 888 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 6 ms 1004 KB
12.txt AC 6 ms 1004 KB
13.txt AC 6 ms 1004 KB