Submission #1276744


Source Code Expand

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;

    for(int i=0; i<4; ++i){
        string ans(n, ' ');
        ans[0] = (i&1) ? 'S' : 'W';
        ans[1] = (i&2) ? 'S' : 'W';

        for(int j=1; j<n-1; ++j){
            if((ans[j] == 'W') ^ (s[j] == 'x'))
                ans[j+1] = 'S' + 'W' - ans[j-1];
            else
                ans[j+1] = ans[j-1];
        }

        if((ans[0] == 'W') ^ (s[0] == 'x') ^ (ans[n-1] != ans[1]))
            continue;
        if((ans[n-1] == 'W') ^ (s[n-1] == 'x') ^ (ans[n-2] != ans[0]))
            continue;

        cout << ans << endl;
        return 0;
    }

    cout << -1 << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User mamekin
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1165 Byte
Status AC
Exec Time 7 ms
Memory 512 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 5 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 6 ms 512 KB
06.txt AC 7 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 5 ms 512 KB
12.txt AC 5 ms 512 KB
13.txt AC 7 ms 512 KB