Submission #1365869


Source Code Expand

#include <iostream>
#include <vector>

int main() {
  unsigned N;
  std::cin >> N;
  std::string s;
  std::cin >> s;
  std::vector<bool> sheep(N);
  auto same = [] (bool which, char c) {
    return (which == (c == 'o'));
  };
  for (unsigned i = 0; i < 4; ++i) {
    sheep[0] = i % 2 == 0;
    sheep[1] = i / 2 == 0;
    for (unsigned j = 2; j < N; ++j) {
      if (same(sheep[j-1], s[j-1])) {
        sheep[j] = sheep[j-2];
      } else {
        sheep[j] = !sheep[j-2];
      }
    }
    if (same(sheep[N-1], s[N-1]) == (sheep[N-2] == sheep[0])) {
      if (same(sheep[0], s[0]) == (sheep[N-1] == sheep[1])) {
        for (auto p = sheep.begin(); p < sheep.end(); ++p) {
          if (*p) { std::cout << "S"; }
          else { std::cout << "W"; }
        }
        return 0;
      }
    }
  }
  std::cout << -1;
  return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User ytsmiling
Language C++14 (Clang 3.8.0)
Score 500
Code Size 862 Byte
Status AC
Exec Time 13 ms
Memory 888 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 7 ms 888 KB
00_example_02.txt AC 1 ms 256 KB
00_example_03.txt AC 1 ms 256 KB
01.txt AC 8 ms 512 KB
02.txt AC 5 ms 384 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 10 ms 512 KB
06.txt AC 9 ms 512 KB
07.txt AC 3 ms 256 KB
08.txt AC 3 ms 384 KB
09.txt AC 2 ms 256 KB
10.txt AC 3 ms 256 KB
11.txt AC 13 ms 576 KB
12.txt AC 13 ms 576 KB
13.txt AC 11 ms 576 KB