반응형
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;}
}
'Algorithm > Implementation' 카테고리의 다른 글
(Rust) - 백준(BOJ) 1000번 : A + B (0) | 2021.08.10 |
---|---|
(Rust) - 백준(BOJ) 2557번 : Hello World (0) | 2021.08.07 |
(C++) - 백준(BOJ) 11093번 : Secret Message (0) | 2021.08.03 |
(C++) - 백준(BOJ) 10551번 : STROJOPIS (0) | 2021.08.03 |
(C++) - 백준(BOJ) 9947번 : Coin tossing (0) | 2021.08.03 |