알고리즘

[알고리즘] 백준 3028 - 창영마을 (C++)

blueberrysoda 2024. 12. 23. 23:21

[문제 링크] : https://www.acmicpc.net/problem/3028

#include <iostream>
#include <algorithm> 
using namespace std;

int Arr[4] = {0, 1, 0, 0};

int main(){
    string S;
    cin >> S;

    for(int i=0; i<S.size(); i++){
        if(S[i] == 'A'){
            swap(Arr[1], Arr[2]);
        }
        else if(S[i] == 'B'){
            swap(Arr[2], Arr[3]);
        }
        else if(S[i] == 'C'){
            swap(Arr[1], Arr[3]);
        }
    }

    for(int i=0; i<4; i++){
        if(Arr[i] == 1){
            cout << i;
        }
    }
    cout << "\n";
    return 0;
}