Submission #1512340


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N;
string S;
bool isSheep[100100];

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N;
    string S;
    std::cin >> S;
    S += S[0];

    for(int i=0;i<2;++i){
        for(int j=0;j<2;++j){
            isSheep[0] = i;
            isSheep[1] = j;
            
            for(int k=1;k<N+1;++k){
                if(isSheep[k]){ // sheep
                    isSheep[k+1] = S[k] == 'o' ? isSheep[k-1] : !isSheep[k-1];
                }else{ // wolf
                    isSheep[k+1] = S[k] == 'x' ? isSheep[k-1] : !isSheep[k-1];
                }
            }

            // for(int k=0;k<N+1;++k){
            //     std::cout << isSheep[k] << std::endl;
            // }
            // std::cout << "----------" << std::endl;
            
            if(isSheep[0] == isSheep[N] && isSheep[1] == isSheep[N+1]){
                for(int k=0;k<N;++k){
                    std::cout << (isSheep[k] ? "S" : "W");
                }
                std::cout << std::endl;
                return 0;
            }
        }
    }

    std::cout << -1 << std::endl;
}

Submission Info

Submission Time
Task D - Menagerie
User iwashisnake
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1503 Byte
Status AC
Exec Time 6 ms
Memory 720 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 4 ms 512 KB
02.txt AC 3 ms 384 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 5 ms 640 KB
06.txt AC 6 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 256 KB
11.txt AC 5 ms 720 KB
12.txt AC 5 ms 720 KB
13.txt AC 6 ms 720 KB