Submission #1368494


Source Code Expand

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MAXN (100005)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef long double ld;

char str[MAXN];
bool chk[MAXN];
int N;

void prans() {
    for(int i = 0; i < N; i++) putchar(chk[i] ? 'S' : 'W');
    puts(""); exit(0);
}
bool f() {
    for(int i = 2; i < N; i++) {
        chk[i] = ('o' == str[i-1]) ^ chk[i-1] ^ chk[i-2];
    }
    for(int i = 1; i+1 < N; i++)
        if(('o' == str[i]) ^ chk[i-1] ^ chk[i] ^ chk[i+1]) return false;
    if(('o' == str[0]) ^ chk[N-1] ^ chk[0] ^ chk[1]) return false;
    if(('o' == str[N-1]) ^ chk[N-2] ^ chk[N-1] ^ chk[0]) return false;
    return true;
}
int main() {
    scanf("%d %s", &N, str);
    if(f()) prans(); chk[1] = true; if(f()) prans();
    chk[0] = true; if(f()) prans(); chk[1] = false; if(f()) prans();
    puts("-1");
    return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User youngyojun
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1582 Byte
Status AC
Exec Time 3 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:54:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %s", &N, str);
                            ^

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 2 ms 384 KB
02.txt AC 2 ms 384 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 3 ms 512 KB
06.txt AC 3 ms 512 KB
07.txt AC 1 ms 256 KB
08.txt AC 2 ms 256 KB
09.txt AC 1 ms 256 KB
10.txt AC 1 ms 256 KB
11.txt AC 3 ms 512 KB
12.txt AC 3 ms 512 KB
13.txt AC 3 ms 512 KB