【BZOJ 4801】打牌

相关链接

题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4801

解题报告

大暴搜游戏题
复杂度:$O(4T)$

Code

#include<bits/stdc++.h>
#define LL long long
using namespace std;
 
int a[5][5],cur[3][3];
 
inline int read() {
    char s[5]; scanf("%s",s);
    if (s[0] == 'A') return 14;
    if (s[0] == 'K') return 13;
    if (s[0] == 'Q') return 12;
    if (s[0] == 'J') return 11;
    if (s[0] == 'T') return 10;
    return s[0] - '0';
}
 
inline int val(int x) {
    if (x == 14) return 1;
    else return x; 
}
 
int solve(int t) {
    if (t == 1) {
        cur[0][0] = a[0][0]; cur[0][1] = a[0][1];
        int s1 = solve(2); 
        swap(cur[0][0], cur[0][1]);
        int s2 = solve(2);
        return max(s1, s2);  
    } else if (t == 2) {
        cur[1][0] = a[1][0]; cur[1][1] = a[1][1];
        int s1 = solve(3);
        swap(cur[1][0], cur[1][1]);
        int s2 = solve(3);
        return min(s1, s2);
    } else {
         if (cur[0][0] >= cur[1][0]) {
            if (cur[0][1] >= cur[1][1]) {
                return val(cur[0][0]) + val(cur[0][1]);
            } else {
                return val(cur[0][0]) - val(cur[1][1]);
            } 
         } else {
            if (cur[0][1] > cur[1][1]) {
                return -val(cur[1][0]) + val(cur[0][1]);    
            } else {
                return -val(cur[1][0]) - val(cur[1][1]) ;
            }
         }
    }
}
 
int main() {
    int t; cin>>t; 
    for (;t;t--) {
        a[0][0] = read(); a[0][1] = read();
        a[1][0] = read(); a[1][1] = read();
        printf("%d\n",solve(1));
    }
    return 0;
}

344 thoughts to “【BZOJ 4801】打牌”

  1. Awesome site you have here but I was curious about
    if you knew of any message boards that cover the same
    topics talked about in this article? I’d really love to be a
    part of community where I can get opinions from other experienced individuals that share the same interest.
    If you have any suggestions, please let me know.
    Thanks a lot!

  2. Pretty nice post. I just stumbled upon your weblog and wished to say that I’ve truly enjoyed surfing around
    your blog posts. In any case I will be subscribing to your rss feed and I hope
    you write again soon!

  3. Its like you read my mind! You seem to know a lot about this, like you wrote the book
    in it or something. I think that you can do with some pics
    to drive the message home a little bit, but instead of that, this is fantastic blog.

    An excellent read. I’ll definitely be back.

  4. I really like your blog.. very nice colors & theme.
    Did you design this website yourself or did you hire someone to do it for you?
    Plz answer back as I’m looking to construct my own blog and would like to know where u got this from.
    many thanks

  5. Hello there! This is kind of off topic but I need some help
    from an established blog. Is it very difficult to set up your own blog?
    I’m not very techincal but I can figure things out pretty fast.

    I’m thinking about setting up my own but I’m not sure where to begin. Do you have
    any tips or suggestions? Many thanks

  6. This is the right blog for everyone who wants to find out about this topic.
    You know so much its almost hard to argue with you (not that I actually will need to…HaHa).
    You definitely put a fresh spin on a topic
    that has been written about for years. Wonderful stuff, just great!

  7. You’re so awesome! I don’t suppose I’ve read through anything like this before.
    So good to find somebody with some original thoughts on this topic.
    Seriously.. thank you for starting this up. This site is one thing that is
    needed on the web, someone with a bit of originality!

  8. Wow that was unusual. I just wrote an incredibly long comment but after I
    clicked submit my comment didn’t appear. Grrrr…

    well I’m not writing all that over again. Regardless, just wanted to say great blog!

  9. Hi! This post couldn’t be written any better!
    Reading through this post reminds me of my previous room mate!
    He always kept chatting about this. I will forward this article to him.
    Pretty sure he will have a good read. Many thanks
    for sharing!

  10. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get three e-mails with the
    same comment. Is there any way you can remove people from that service?
    Thank you!

  11. I got this website from my friend who told me regarding this web page and now this time I am visiting this
    web page and reading very informative articles or reviews here.
    natalielise plenty of fish

  12. What’s up everyone, it’s my first go to see at this website, and paragraph is really fruitful designed for me, keep up posting
    these types of articles. natalielise plenty of fish

  13. Hey are using WordPress for your blog platform?
    I’m new to the blog world but I’m trying to get started and set up
    my own. Do you need any coding knowledge to make your own blog?
    Any help would be greatly appreciated!

  14. I’m very pleased to uncover this site. I need to to thank you
    for ones time due to this wonderful read!! I definitely savored every
    part of it and I have you saved as a favorite to see new stuff
    in your website.

  15. Thank you, I’ve just been looking for info about this subject for a long
    time and yours is the greatest I have came
    upon till now. However, what concerning the conclusion? Are you certain concerning the source?

  16. Hello there! This blog post couldn’t be written any better!
    Reading through this post reminds me of my previous roommate!
    He always kept preaching about this. I’ll send this article to
    him. Pretty sure he will have a good read. Many thanks for sharing!

  17. I feel that is among the such a lot important info for me.
    And i’m satisfied studying your article. But want to observation on few general issues,
    The site style is ideal, the articles is in reality excellent :
    D. Just right task, cheers

  18. Amazing! This blog looks exactly like my old one!
    It’s on a entirely different subject but it has pretty much the same page layout and
    design. Outstanding choice of colors!

  19. Nice post. I learn something new and challenging on websites I stumbleupon every day.

    It will always be helpful to read articles from other authors
    and use something from other websites.

  20. hello!,I really like your writing very so much!
    share we keep up a correspondence more approximately your post on AOL?
    I require an expert on this house to solve my problem.
    May be that is you! Taking a look forward to peer you.

  21. Hi there, just became alert to your blog through Google, and found that it’s really informative.
    I am gonna watch out for brussels. I’ll appreciate if you
    continue this in future. Many people will be benefited from your writing.
    Cheers!

  22. Hi, I think your blog might be having browser compatibility issues.
    When I look at your blog in Firefox, it looks fine but when opening in Internet
    Explorer, it has some overlapping. I just wanted to give you a
    quick heads up! Other then that, great blog!

  23. I was recommended this website by my cousin.
    I’m not sure whether this post is written by him as nobody else know such detailed about my
    difficulty. You’re amazing! Thanks!

  24. Hi there! This is my 1st comment here so I just wanted to
    give a quick shout out and say I genuinely enjoy reading your posts.
    Can you recommend any other blogs/websites/forums that deal with the same
    topics? Appreciate it!

  25. Thanks for your personal marvelous posting! I genuinely enjoyed reading it, you could
    be a great author. I will always bookmark your blog and may come back at some point.
    I want to encourage that you continue your great work,
    have a nice weekend!

  26. I’m curious to find out what blog platform you are utilizing?
    I’m experiencing some minor security problems with my latest website
    and I’d like to find something more risk-free. Do you have any suggestions?

  27. I think this is one of the most significant information for me.
    And i am glad reading your article. But should remark on few general things,
    The web site style is perfect, the articles is really excellent :
    D. Good job, cheers

  28. It’s appropriate time to make some plans for the longer term and it’s time to
    be happy. I have read this post and if I may
    just I desire to suggest you few interesting issues or tips.

    Perhaps you could write subsequent articles
    relating to this article. I want to learn more issues about it!

  29. Excellent article. Keep writing such kind of info on your site.
    Im really impressed by your blog.
    Hey there, You’ve performed a fantastic job. I’ll definitely
    digg it and for my part suggest to my friends. I’m confident they will be benefited from this
    site.

  30. Hello, Neat post. There is an issue together with your website in web explorer, might test this?
    IE still is the marketplace chief and a huge section of
    other people will leave out your magnificent writing because of this problem.

  31. It’s a shame you don’t have a donate button! I’d certainly donate to this superb blog!
    I guess for now i’ll settle for bookmarking and adding
    your RSS feed to my Google account. I look forward to fresh updates and will share this blog with
    my Facebook group. Talk soon!

  32. Thank you for any other great post. The place
    else may anybody get that type of info in such a perfect means of writing?
    I’ve a presentation subsequent week, and I’m at the search for such information.

  33. hey there and thank you for your info – I have certainly picked up anything new from right
    here. I did however expertise some technical points using
    this website, as I experienced to reload the web site a lot of times previous to I could get it to load correctly.

    I had been wondering if your web host is OK? Not that I’m complaining, but
    slow loading instances times will often affect your placement in google and can damage your high-quality score if
    ads and marketing with Adwords. Well I’m adding this RSS to my email and
    can look out for a lot more of your respective exciting content.
    Ensure that you update this again very soon.

  34. Hello! I just wanted to ask if you ever have any problems with hackers?
    My last blog (wordpress) was hacked and I ended up losing many months of hard
    work due to no back up. Do you have any methods to prevent
    hackers?

  35. I am not sure where you are getting your information, but good topic.
    I needs to spend some time learning more or understanding more.
    Thanks for fantastic information I was looking for this info for my mission.

  36. This design is spectacular! You most certainly know how to
    keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog
    (well, almost…HaHa!) Fantastic job. I really loved what you had to say, and more than that,
    how you presented it. Too cool!

  37. First of all I want to say excellent blog! I had a quick question which I’d like to ask if you do not
    mind. I was curious to find out how you center yourself and clear your head prior to writing.

    I’ve had a hard time clearing my thoughts in getting my ideas
    out there. I truly do enjoy writing but it just seems
    like the first 10 to 15 minutes are usually lost simply just trying to figure out how to begin. Any recommendations or hints?

    Kudos!

  38. Wow, superb blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your web
    site is great, let alone the content!

  39. It’s really very complex in this busy life to listen news on TV, thus I simply use world wide web for that reason, and get the hottest
    information.

  40. I think this website has got some really fantastic information for everyone. “The best friend is the man who in wishing me well wishes it for my sake.” by Aristotle.

  41. First off I want to say awesome blog! I had a
    quick question that I’d like to ask if you don’t mind.
    I was curious to know how you center yourself and clear your mind before writing.
    I have had a difficult time clearing my thoughts in getting my ideas out.
    I truly do enjoy writing however it just seems like the first
    10 to 15 minutes are generally lost just trying
    to figure out how to begin. Any recommendations or hints?
    Cheers!

  42. You really make it appear so easy with your presentation but I
    find this matter to be actually something which I feel I
    might by no means understand. It sort of feels too complex
    and very huge for me. I’m looking forward to your
    next put up, I will try to get the cling of it!

  43. I’ve been exploring for a bit for any high quality articles or weblog posts in this kind
    of area . Exploring in Yahoo I finally stumbled
    upon this website. Studying this information So i’m happy to express that I have
    a very good uncanny feeling I came upon just what I needed.
    I so much without a doubt will make certain to don?t disregard this site and provides it
    a look on a constant basis.

  44. I believe everybody went like Ones New website, reason being things like this site without doubt has a article on quality. I loved read A New content. go on To remain a useful article, I will avail Once more by One additional time. Bless you.

  45. I’ve been browsing online more than 4 hours today, yet I never found any
    interesting article like yours. It’s pretty worth
    enough for me. In my view, if all site owners and
    bloggers made good content as you did, the internet will be
    a lot more useful than ever before.

  46. I believe this is one of the so much significant info for me. And i am happy reading your article. But should commentary on some common things, The site style is perfect, the articles is actually excellent : D. Just right task, cheers

  47. Hmm it appears like your website ate my first comment (it was extremelylong) so I guess I’ll just sum it up what I had written andsay, I’m thoroughly enjoying your blog. I as wellam an aspiring blog blogger but I’m still new tothe whole thing. Do you have any helpful hints for novice blog writers?I’d really appreciate it.

  48. Awesome write-up. I’m a regular visitor of your website and appreciate you taking the time to maintain the excellent site. I will be a frequent visitor for a really long time.

  49. It’а†s really a cool and helpful piece of info. I am satisfied that you shared this useful info with us. Please stay us informed like this. Thank you for sharing.

  50. Hi, i feel that i saw you visited my web siteso i came to go back the choose?.I am attempting to in findingthings to enhance my site!I guess its adequate to use a fewof your ideas!!

  51. Does your site have a contact page? I’m having a tough time locating it but, I’d like to shoot you an email. I’ve got some suggestions for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it improve over time.|

  52. I’ve been browsing online greater than three hours nowadays, yet I by no means found any attention-grabbing article like yours. It’s pretty value enough for me. In my opinion, if all website owners and bloggers made excellent content material as you did, the net might be a lot more useful than ever before.|

  53. Hello there! I know this is somewhat off topic but I was wondering which blog platform are you using for this site? I’m getting tired of WordPress because I’ve had problems with hackers and I’m looking at options for another platform. I would be fantastic if you could point me in the direction of a good platform.|

  54. I love your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do it for you? Plz answer back as I’m looking to construct my own blog and would like to know where u got this from. kudos|

  55. Hello, Neat post. There is a problem along with your web site in web explorer, would test this¡K IE nonetheless is the marketplace chief and a large element of folks will miss your great writing due to this problem.

  56. I do consider all of the concepts you’ve offered on your post. They are very convincing and can definitely work. Nonetheless, the posts are very brief for newbies. May you please prolong them a little from subsequent time? Thanks for the post.|

  57. Hi there, I found your web site by means of Google whilst looking for a similar matter, your web site came up, it seems to be good. I have bookmarked it in my google bookmarks.

  58. Fantastic beat ! I wish to apprentice while you amend your site, how could i subscribe for a blog web site? The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear concept

  59. Hmm it appears like your site ate my first comment (it was super long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to the whole thing. Do you have any tips for novice blog writers? I’d genuinely appreciate it.|

  60. Good day! I could have sworn I’ve visited this site before but after looking at a few of the posts I realized it’s new to me. Nonetheless, I’m certainly happy I discovered it and I’ll be bookmarking it and checking back often!|

  61. I think this is among the most significant information for me. And i’m glad reading your article. But should remark on some general things, The site style is wonderful, the articles is really nice : D. Good job, cheers|

  62. Hello there, You have done an incredible job. I’ll definitely digg it and personally recommend to my friends. I’m sure they’ll be benefited from this website.|

  63. Thanks for a marvelous posting! I certainly enjoyed reading it, you could be a great author. I will be sure to bookmark your blog and will come back sometime soon. I want to encourage one to continue your great job, have a nice weekend!|

Leave a Reply

Your email address will not be published. Required fields are marked *