URI ONLINE JUDGE SOLUTION 1337 - Online Judge

Latest

This is an Online Judge Solution Base Site. We can discuss & Solve any contest solution in Programming.

Friday, April 10, 2020

URI ONLINE JUDGE SOLUTION 1337

Problem Number: 1337
Problem Name: King’s Poker
Author’s Name: By Ricardo Anido Brazil
Timelimit: 1
Problem Category: AD-HOC
Problem Source: https://www.urionlinejudge.com.br/judge/en/problems/view/1337

Solution:

#include <cstdio>
#include <algorithm>

#define sc3(a, b, c) scanf("%d %d %d", &a, &b, &c)

using namespace std;

int hand[3];

int main(int argc, char const *argv[])
{
    int a, b, c;
    bool s, p;

    while(sc3(hand[0], hand[1], hand[2]) && hand[0])
    {
        sort(hand, hand + 3);
        a = hand[0], b = hand[1], c = hand[2];
        s = p = false;

        if(a == b && a == c) s = true;
        if(a == b || b == c) p = true;

        if(s){
            if(a == 13) printf("*n");
            else printf("%d %d %dn", a + 1, a + 1, a + 1);
        }else if(p){
            if(a == b){
                if(c == 13) printf("%d %d %dn", 1, ++a, a);
                else printf("%d %d %dn", a, a, c + 1);
            }else{
                if(c == 13){
                    if(a == 12) printf("1 1 1n");
                    else printf("%d %d %dn", a + 1, b, b);
                }else{
                    if(a + 1 == b) printf("%d %d %dn", b, b, a + 2);
                    else printf("%d %d %dn", a + 1, b, b);
                }
            }
        }else printf("1 1 2n");
    }

    return 0;
}

No comments:

Post a Comment

Thanks..