USACO/Bronze

백준 14456 Hoof, Paper, Scissors (USACO January 2017 Bronze 2번)

ssam.. 2020. 2. 29. 19:46

문제 링크: https://www.acmicpc.net/problem/14456

 

14456번: Hoof, Paper, Scissors (Bronze)

You have probably heard of the game "Rock, Paper, Scissors". The cows like to play a similar game they call "Hoof, Paper, Scissors". The rules of "Hoof, Paper, Scissors" are simple. Two cows play against each-other. They both count to three and then each s

www.acmicpc.net

가능한 상황이 두가지밖에 없다.

1. 1이 2를 이기고, 2가 3을 이기고, 3이 1을 이기는 경우.

2. 1이 2한테 지고, 2가 3한테 지고, 3이 1한테 지는 경우.

두가지 경우에 대해서 첫번째 소가 이기는 수의 최대값을 구함.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <bits/stdc++.h>
using namespace std;
 
int N, cnt1, cnt2;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    cin >> N;
    while(N--) {
        int a, b;
        cin >> a >> b;
 
        if((a == 1 && b == 2|| (a == 2 && b == 3|| (a == 3 && b == 1)) cnt1++;
        else if((a == 1 && b == 3|| (a == 3 && b == 2|| (a == 2 && b == 1)) cnt2++;
    }
 
    cout << max(cnt1, cnt2) << '\n';
    return 0;
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter