Submission #1414623


Source Code Expand

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

typedef long long ll;

char buf[100000+10];
char res[100000+10];

int main(void) {
  ll n;
  cin >> n >> buf;

  REP(pat, 4) {
    memset(res, 0, sizeof res);
    res[n-1] = (pat & 1) ? 'S' : 'W';
    res[n-2] = (pat & 2) ? 'S' : 'W';
    bool ok = true;
    REP(i, n) {
      int count = 0;
      count += res[(i-1+n)%n] == 'S';
      count += res[(i-2+n)%n] == 'S';
      char tobe = !!(count % 2) == !!(buf[(i-1+n)%n] == 'o') ? 'W' : 'S';
      if(res[i] && res[i] != tobe) {
        ok = false;
      } else {
        res[i] = tobe;
      }
    }
    if(ok) {
      puts(res);
      return 0;
    }
  }
  puts("-1");
  
  return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User ush
Language C++14 (GCC 5.4.1)
Score 500
Code Size 855 Byte
Status AC
Exec Time 12 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 384 KB
00_example_02.txt AC 1 ms 384 KB
00_example_03.txt AC 1 ms 384 KB
01.txt AC 4 ms 512 KB
02.txt AC 4 ms 384 KB
03.txt AC 1 ms 384 KB
04.txt AC 1 ms 384 KB
05.txt AC 6 ms 512 KB
06.txt AC 12 ms 512 KB
07.txt AC 3 ms 384 KB
08.txt AC 3 ms 384 KB
09.txt AC 1 ms 384 KB
10.txt AC 3 ms 384 KB
11.txt AC 9 ms 512 KB
12.txt AC 9 ms 512 KB
13.txt AC 11 ms 512 KB