Submission #1379649


Source Code Expand

#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50

int N;string s;
string res="";

bool f(){
    FOR(i,1,N-1){
        if(s[i]=='o'&&res[i]=='S'&&res[i-1]=='S'){
            res+='S';
        }else if(s[i]=='o'&&res[i]=='W'&&res[i-1]=='S'){
            res+='W';
        }else if(s[i]=='o'&&res[i]=='S'&&res[i-1]=='W'){
            res+='W';
        }else if(s[i]=='o'&&res[i]=='W'&&res[i-1]=='W'){
            res+='S';
        }else if(s[i]=='x'&&res[i]=='S'&&res[i-1]=='S'){
            res+='W';
        }else if(s[i]=='x'&&res[i]=='W'&&res[i-1]=='S'){
            res+='S';
        }else if(s[i]=='x'&&res[i]=='S'&&res[i-1]=='W'){
            res+='S';
        }else if(s[i]=='x'&&res[i]=='W'&&res[i-1]=='W'){
            res+='W';
        }
    }
    if(s[0]=='o'){
        if(res[0]=='S'&&res[1]=='S'){
            return res[N-1]=='S';
        }else if(res[0]=='S'&&res[1]=='W'){
            return res[N-1]=='W';
        }else if(res[0]=='W'&&res[1]=='S'){
            return res[N-1]=='W';
        }else if(res[0]=='W'&&res[1]=='W'){
            return res[N-1]=='S';
        }
    }else{
        if(res[0]=='S'&&res[1]=='S'){
            return res[N-1]=='W';
        }else if(res[0]=='S'&&res[1]=='W'){
            return res[N-1]=='S';
        }else if(res[0]=='W'&&res[1]=='S'){
            return res[N-1]=='S';
        }else if(res[0]=='W'&&res[1]=='W'){
            return res[N-1]=='W';
        }
    }
}

int main(){
    cin>>N;cin>>s;
    res="SS";
    if(f()){
        cout<<res<<endl;return 0;
    }
    res="SW";
    if(f()){
        cout<<res<<endl;return 0;
    }
    res="WS";
    if(f()){
        cout<<res<<endl;return 0;
    }
    res="WW";
    if(f()){
        cout<<res<<endl;return 0;
    }
    cout<<-1<<endl;
    return 0;
}

Submission Info

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

Judge Result

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