알고리즘

[알고리즘] 백준 4493 - 가위 바위 보? (C++)

blueberrysoda 2024. 12. 2. 23:57

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

#include <iostream> 
using namespace std;

int main(){
    int N, inp;
    cin >> N;
 
    char A, B;
    
    for(int i=0; i<N; i++){
        int a = 0, b = 0;
        cin >> inp;
 
        for(int i=0; i<inp; i++){
            cin >> A >> B;
 
            if(A == 'R'){
                if(B == 'R'){
                    a++;
                    b++;
                }
                else if(B == 'S'){
                    a++;
                }
                if(B == 'P'){
                    b++;
                }
            }
            else if(A == 'S'){
                if(B == 'R'){
                    b++;
                }
                else if(B == 'S'){
                    a++;
                    b++;
                }
                if(B == 'P'){
                    a++;
                }
            }
            else if(A == 'P'){
                if(B == 'R'){
                    a++;
                }
                else if(B == 'S'){
                    b++;
                }
                if(B == 'P'){
                    a++;
                    b++;
                }
            }
        }
        if(a > b){
            cout << "Player 1\n";
        }
        else if(b > a){
            cout << "Player 2\n";
        }
        else if(a==b){
            cout << "TIE\n";
        }
    }
    return 0;
}