Submission #3616603


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[5] = {true, false, true, false};
vector<bool> vec;

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

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  for(int i = 0; i < 4; i++){
    vec.clear();
    bool prev_sheep = is_sheep0[i];
    bool curr_sheep = is_sheep1[i];
    vec.pb(prev_sheep);
    vec.pb(curr_sheep);
    for(int j = 1; j < n; j++){
      if(j == n - 1){
        if(curr_sheep){
          if(s[j] == 'o' && prev_sheep != is_sheep0[i])break;
          if(s[j] == 'x' && prev_sheep == is_sheep0[i])break;
        }else{
          if(s[j] == 'o' && prev_sheep == is_sheep0[i])break;
          if(s[j] == 'x' && prev_sheep != is_sheep0[i])break;
        }
        if(is_sheep0[i]){
          if(curr_sheep == is_sheep1[i]){
            dump();
            return 0;
          }
        }else{
          if(curr_sheep != is_sheep1[i]){
            dump();
            return 0;
          }
        }
      }else{
        if(curr_sheep){
          if(s[j] == 'o'){
            swap(prev_sheep, curr_sheep);
          }else{
            bool tmp = curr_sheep;
            curr_sheep = !prev_sheep;
            prev_sheep = tmp;
          }
        }else{
          if(s[j] == 'o'){
            bool tmp = curr_sheep;
            curr_sheep = !prev_sheep;
            prev_sheep = tmp;
          }else{
            swap(prev_sheep, curr_sheep);
          }
        }
        vec.pb(curr_sheep);
      }
    }
  }
  cout << - 1 << endl;
	return 0;
}

Submission Info

Submission Time
Task D - Menagerie
User fumiphys
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2295 Byte
Status WA
Exec Time 11 ms
Memory 512 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 13
WA × 3
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 WA 3 ms 256 KB
09.txt WA 2 ms 256 KB
10.txt WA 3 ms 256 KB
11.txt AC 11 ms 512 KB
12.txt AC 11 ms 512 KB
13.txt AC 10 ms 512 KB