Submission #3616806


Source Code Expand

#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

bool is_sheep0[4] = {true, true, false, false};
bool is_sheep1[4] = {true, false, true, false};
vector<bool> sheep;
int n;
string s;

bool check(){
  if(((sheep[n - 1] && s[n - 1] == 'o') || (!sheep[n - 1] && s[n - 1] == 'x')) && sheep[n - 2] != sheep[0])return false;
  if(((sheep[n - 1] && s[n - 1] == 'x') || (!sheep[n - 1] && s[n - 1] == 'o')) && sheep[n - 2] == sheep[0])return false;
  if(((sheep[0] && s[0] == 'o') || (!sheep[0] && s[0] == 'x')) && sheep[n - 1] != sheep[1])return false;
  if(((sheep[0] && s[0] == 'x') || (!sheep[0] && s[0] == 'o')) && sheep[n - 1] == sheep[1])return false;
  return true;
}

void dump() {
  for(int i = 0; i < n; i++){
    if(sheep[i])cout << 'S';
    else cout << 'W';
  }
  cout << endl;
}

int main(int argc, char const* argv[])
{
  cin >> n;
  cin >> s;
  sheep = vector<bool>(n, false);
  for(int i = 0; i < 4; i++){
    sheep[0] = is_sheep0[i];
    sheep[1] = is_sheep1[i];
    for(int j = 1; j < n - 1; j++){
      if((sheep[j] && s[j] == 'o') || (!sheep[j] && s[j] == 'x')){
        sheep[j + 1] = sheep[j - 1];
      }else{
        sheep[j + 1] = !sheep[j - 1];
      }
    }
    if(check()){
      dump();
      return 0;
    }
  }
  cout << - 1 << endl;
	return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User fumiphys
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1860 Byte
Status AC
Exec Time 11 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 256 KB
00_example_02.txt AC 1 ms 256 KB
00_example_03.txt AC 1 ms 256 KB
01.txt AC 7 ms 384 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 9 ms 512 KB
06.txt AC 8 ms 512 KB
07.txt AC 3 ms 256 KB
08.txt AC 3 ms 256 KB
09.txt AC 1 ms 256 KB
10.txt AC 2 ms 256 KB
11.txt AC 11 ms 512 KB
12.txt AC 11 ms 512 KB
13.txt AC 10 ms 512 KB