본문 바로가기

Algorithm/Implementation

(C++) - 백준(BOJ) 13224번 : Chop Cup

반응형

https://www.acmicpc.net/problem/13224

 

13224번: Chop Cup

Oisín is amateur magician and is big fan of Chop Cup routine which involves three cups face down and one ball underneath one of the cups. He's only started to practice the trick and wants to test out if you can follow where the ball is without any tricks

www.acmicpc.net

구현문제였습니다.

 

 

 

📕 Code

#include <bits/stdc++.h>
using namespace std;
int cup[4] {0,1,0,0};
string s;
int main(){
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A') swap(cup[1],cup[2]);
        else if(s[i] == 'B') swap(cup[2],cup[3]);
        else swap(cup[1],cup[3]);
    }
    for(int i = 1; i <= 3; i++) if(cup[i]) { cout << i; break;}
}