Submission #2831699


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

int reverse(char s) {
  if (s == 'S') return 'W';
  if (s == 'W') return 'S';
  return 0;
}
int may_reverse(bool flag, char s) {
  if (flag) {
    if (s == 'S') return 'W';
    if (s == 'W') return 'S';
  }
  return s;
}

int n;
int next(int i) {
  if (++i == n) return 0;
  return i;
}
int prev(int i) {
  if (--i < 0) return n-1;
  return i;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> n >> s;

  string assume;
  assume.resize(n);
  char type[] = "SW";
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      assume[1] = type[j];
      assume[0] = type[i];

      int pos = 1;
      for (int k = 0; k < n + 2; ++k) {
        assume[next(pos)] =
          may_reverse(assume[pos] == 'S' ^ s[pos] == 'o',
                      assume[prev(pos)]);
        pos = next(pos);
      }
      if (assume[0] == type[i] && assume[1] == type[j]) {
        cout << assume <<" \n";
        return 0;
      }

    }
  }
  cout << -1 << "\n";
}

Submission Info

Submission Time
Task D - Menagerie
User kumagi
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1101 Byte
Status AC
Exec Time 5 ms
Memory 640 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 3 ms 512 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 4 ms 640 KB
06.txt AC 2 ms 640 KB
07.txt AC 2 ms 384 KB
08.txt AC 2 ms 384 KB
09.txt AC 1 ms 256 KB
10.txt AC 2 ms 384 KB
11.txt AC 5 ms 592 KB
12.txt AC 5 ms 592 KB
13.txt AC 4 ms 592 KB