• URAL 1784 K


    K - Rounders
    Time Limit: 20 Sec

    Memory Limit: 256 MB

    题目连接

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87643#problem/K

    Description

    After the shameful loss in the match against Jesus Quintana, The Dude, Donny and Walter decided to turn to poker and become rounders. First of all, they decided to learn to deal with cards.
    Walter gave Donny a simple task—he should split a deck of 52 cards into four piles in such a way that cards in each pile would be sorted in the order of ascending value. Two should be the topmost card, three should be the next card and so on. Ace should lie in the bottom. Walter wanted all decks to be comprised of the cards of the same suit but he forgot to mention it. As a result, the suits in piles were shuffled.
    The Dude decided to save the day. But after five White Russians he poured into himself yesterday he isn't in a good condition for thinking. In fact, he is able to perform only the following actions:
    • take a few cards of one suit from the top of a deck and create a new deck of them;
    • take a few cards of one suit from the top of a deck and put them onto a card which value is greater by one than the value of the bottommost of the taken cards.
    The Dude doesn't change the order of cards while moving them.
    Help The Dude to complete Walter's task before Walter get insane and shoot both his best friends with Uzi.
     

    Input

    The input consists of four lines describing the piles of cards. Each line contains the description of 13 cards in a pile in order from top to bottom (that is, in the order of ascending values). Each card is denoted by its value and its suit. The value is one of the following: 2, 3, …, 9, T (ten), J (jack), Q (queen), K (king), A (ace), the suit can be: S (spades), C (clubs), D (diamonds) or H (hearts). All cards in the input are different.

    Output

    Output the minimal number of operations The Dude should perform in order to obtain four piles consisting of cards with the same suit.

    Sample Input

    2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC AC
    2S 3S 4S 5S 6S 7S 8D 9D TD JD QD KD AD
    2D 3D 4D 5D 6D 7D 8S 9S TS JS QS KS AS
    2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH AH

    Sample Output

    3

    HINT

    题意

    其实就是蜘蛛纸牌啦

    一开始给你4个正确序列的纸牌

    然后每次你就只能从上面拿下来一堆

    然后问你最少几次操作可以得到上面的序列

    题解

    我们对于每一行判断就好了,如果这一行有两个区别的话,那就加3啦,如果有3个区别,就加4,如果有4个区别,那就有两种,特判一下就好了

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 5000
    #define mod 10007
    #define eps 1e-9
    int Num;
    //const int inf=0x7fffffff;   //нчоч╢С
    const int inf=0x3f3f3f3f;
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    //**************************************************************************************
    int s[4][40];
    int main()
    {
        //freopen("test.txt","r",stdin);
        for(int i=0;i<4;i++)
        {
            for(int j=0;j<13;j++)
            {
                string ss;
                cin>>ss;
                if(ss[1]=='C')
                    s[i][j]=1;
                else if(ss[1]=='S')
                    s[i][j]=2;
                else if(ss[1]=='D')
                    s[i][j]=3;
                else  
                    s[i][j]=4;
            }
        }
        int ans=0;
        for(int i=0;i<12;i++)
        {
            int tot=0;
            for(int j=0;j<4;j++)
            {
                if(s[j][i]!=s[j][i+1])
                    tot++;
            }
            if(tot==4)
            {
                int flag=0;
                for(int j=0;j<4;j++)
                {
                    for(int jj=1;jj<4;jj++)
                    {
                        if(s[j][i]==s[jj][i+1]&&s[jj][i]==s[j][i+1])
                            flag=1;
                    }
                }
                if(flag)
                    ans++;
            }
            if(tot>0)
                ans+=tot+1;
        }
        cout<<ans<<endl;
    }
  • 相关阅读:
    临时禁用大型列表上的列表视图阈值
    临时禁用大型列表上的列表视图阈值
    SharePoint Foundation 2010 托管客户端对象模型概述 创建 Windows 控制台托管的客户端对象模型应用程序
    如何隐藏MOSS2010的网站操作菜单
    MOSS2010的列表视图参数设置以及列表记录样式设置
    使用SharePoint Server 2010搜索PDF文档
    Sharepoint2010如何使用Linq to Sharepoint
    水晶報表字段超鏈結4/28
    4月21自考4/23
    [轉]統籌方法華羅庚
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4728621.html
Copyright © 2020-2023  润新知