Translate

Views

Friday, June 2, 2023

Solution UVA: 10646 - What is the Card?

 Click on table to read problem, disscuss, debug!

 Last Submissions
  Problem  VerdictLangTimeBestRankSubmit Time
 | discuss10646 - What is the Card? AcceptedC++110.0400.00025332 mins ago


Sugget:

This is an easy problem but it took me quite a while to read and understand the problem. I think you will if you are not good at English, so I will summarize for you:
- A deck of 52 cards
- You need to split into 2 groups (1 group of 27 and 1 group of 25 cards (top)) 
- In group 27 you need to do ONLY 3 times: Take the top card, calculate its value (X) then add it to Y and discard it, continue to discard 10 - X cards after it (and so on for until 3 times are enough). (*)
- Finally, you combine the group of 25 cards on the group you just performed the operations and output the Yth card

(*): In this step, if you try a few cases, you will see that Y always outputs 33 (11 in 1, 11 in 2, 11 in 3) => You just need to print out the card 33rd (starts with index 1)

#include<bits/stdc++.h>
#define         int                 long long
#define         N                   1000111
#define         oo                  9223372036854775807LL
#define         X                   first
#define         Y                   second
#define         FOR(i, a, b)        for(int i=a; i<=b; i++)
#define         DOW(i, a, b)        for(int i=b; i>=a; i--)
#define         pb                  push_back
#define         popb                pop_back
#define         pf                  push_front
#define         popf                pop_front
#define         forvec(i,a)         for(int i=0; i<a.size(); i++)
#define         for1(i,n)           for(int i=1; i<=n; i++)
#define         for0(i,n)           for(int i=0; i<n; i++)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

int t, n, x, y, z, l, r, k;
string a[N], b[N];
char c[N];
string s;

int32_t main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int t;  cin >> t;
    for1(k, t){
        for1(i, 52){
            cin >> a[i];
        }
        cout<<"Case "<<k<<": "<<a[33]<<"\n";
    }
}

No comments: