Submission #1675589


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

main() {
  int N; cin >> N;
  string s; cin >> s;
  s += s[0];

  string SSWWS("SSWWS");
  string ans;
  for (int i = 0; i < 4; i++) {
    string res = SSWWS.substr(i, 2);
    for (int j = 1; j < N; j++) {
      for (int k = 0; k < 4; k++) {
        if (res.substr(j - 1, 2) == SSWWS.substr(k, 2)) res += (s[j] == 'o') ? "SW"[k % 2] : "WS"[k % 2];
      }
    }
    if (res.back() != res.front()) continue;

    bool ok = false;
    for (int k = 0; k < 4; k++) {
      if (res.substr(N - 1, 2) == SSWWS.substr(k, 2)) {
        if (s[0] == 'o' && res[1] == "SW"[k % 2] || s[0] == 'x' && res[1] == "WS"[k % 2]) ok = true;
      }
    }
    if (ok) ans = res.substr(0, N);
  }
  cout << ( (ans.empty()) ? "-1" : ans ) << endl;
}

Submission Info

Submission Time
Task D - Menagerie
User hrbt
Language C++14 (GCC 5.4.1)
Score 500
Code Size 802 Byte
Status AC
Exec Time 256 ms
Memory 736 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 117 ms 640 KB
02.txt AC 83 ms 512 KB
03.txt AC 5 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 163 ms 656 KB
06.txt AC 170 ms 688 KB
07.txt AC 30 ms 384 KB
08.txt AC 31 ms 384 KB
09.txt AC 9 ms 256 KB
10.txt AC 56 ms 384 KB
11.txt AC 256 ms 688 KB
12.txt AC 184 ms 688 KB
13.txt AC 182 ms 736 KB