[SDOI2010] Swine state killing

Source: Internet
Author: User

One can see the surface: https://mubu.com/doc/2707815814591da4

At night idle Nothing dry be refun to write pig country kill play

And then I wrote it all at once.

Wasted one night + one morning

The rule of a compost gut SB is to let you use their IQ to play pig country kill

It's a matter of no significance.

Attach the 10K code

And the guy who fooled me has been mocking me for the long tat I wrote.

#include <map> #include <cstdio> #include <vector> #include <cstring> #include <iostream> #include <algorithm>const int M = 2005; const int n =, using namespace std; int N, m; int think[n], pnum, Znum    , Fnum; char resp[m]; bool Gameover; struct PIG {int id;    BOOL Isshow;    BOOL cloth;     int HP;    BOOL dead; Vector < char > c;} P[N]; inline bool Win () {if (Fnum = = 0 | | p[1]. HP = = 0) Gameover = true; return gameover;    }inline bool Isfriend (int a, int b) {int x = p[a].id, y = p[b].id;        if (x = = 1 | | x = = 2) {if (y = = 1 | | y = = 2) return true;    else return false;        } else {if (y = = 3) return true;    else return false;        }}inline bool Miss (int now) {for (int i = 0; i < p[now].c.size (); i + +) {char ch = p[now].c[i];            if (ch = = ' D ') {p[now].c.erase (P[now].c.begin () + i);        return true; }} return false;} inline bool Usek (int now) {foR (int i = 0; i < p[now].c.size (); i + +) {char ch = p[now].c[i];            if (ch = = ' K ') {p[now].c.erase (P[now].c.begin () + i);        return true; }} return false;}        inline bool Usej (int now) {for (int i = 0; i < p[now].c.size (); i + +) {char ch = p[now].c[i];            if (ch = = ' J ') {p[now].c.erase (P[now].c.begin () + i);        return true; }} return false;}        inline bool Recover (int now) {for (int i = 0; i < p[now].c.size (); i + +) {char ch = p[now].c[i]; if (ch = = ' P ') {P[now].            HP + +;            P[now].c.erase (P[now].c.begin () + i);        return true; }} return false;} inline void Getcard (int now, int. num) {for (int upp = 1; Upp <= NUM; Pnum + +, UPP + +) {P[now].c.push_bac        K (Resp[pnum]);     if (Pnum = = m) Pnum = m-1;    }}inline bool Kill (int now, int wh) {int Np = 0; for (int i = now + 1; I <= n; i + +) if (!P[i].dead) {Np = i; break;} if (!    NP) for (int i = 1; i < now; i + +) if (!p[i].dead) {Np = i; break;}    if (Np = = 0) return false; if (now = = 1) {if (P[NP].        Isshow && Isfriend (now, Np)) return false; else if (!P[NP].        Isshow &&!THINK[NP]) return false;            else {p[now].c.erase (P[now].c.begin () + WH);            if (Miss (Np)) return true; P[NP].            HP--; if (P[NP].                HP = = 0) {if (Recover (Np)) return true;                    else {p[np].dead = true;                    if (p[np].id = = 3) fnum--;                        else {znum--;                        P[now].cloth = false;                    P[now].c.clear ();                     } if (Win ()) return true; if (!                    Gameover && p[np].id = = 3) Getcard (now, 3); if (p[np].id = = 2) {p[now].c.clear (); p[now].cloth = FALSE; }}}}} else {if (!P[NP].        Isshow) return false; if (P[NP].        Isshow && Isfriend (now, Np)) return false; if (P[NP]. Isshow &&!            Isfriend (now, Np)) {p[now].c.erase (P[now].c.begin () + WH); if (!p[now]. isshow) P[now].            Isshow = true;            if (Miss (Np)) return true; else {P[NP].                HP--; if (P[NP].                    HP = = 0) {if (Recover (Np)) return true;                        else {p[np].dead = true;                        if (p[np].id = = 3) fnum--;                        else Znum--;                         if (Win ()) return true; if (!                    Gameover && p[np].id = = 3) Getcard (now, 3); }}}}} return true;    inline bool Doj (int now, int Np) {int wx =-1; bool Can = true;        while (CAN) {can = false; for (int i = Now ; I <= N;            i + +) {if (p[i].dead) continue; if (Isfriend (Np, i) && P[NP].                     Isshow && WX < 0) {if (Usej (i)) {wx = 1;                    Can = true; P[i].                Isshow = true; }} if (! Isfriend (Np, i) && P[NP].                     Isshow && wx > 0) {if (Usej (i)) {wx =-1;                    Can = true; P[i].                Isshow = true;        }}} if (Can) continue;            for (int i = 1; i < now; i + +) {if (p[i].dead) continue; if (Isfriend (Np, i) && P[NP].                     Isshow && WX < 0) {if (Usej (i)) {wx = 1;                    Can = true; P[i].                Isshow = true; }} if (! Isfriend (Np, i) && P[NP]. Isshow && wx > 0) {if (Usej (i)){WX =-1;                    Can = true; P[i].                Isshow = true;    }}}} if (WX < 0) return false; return true;}    inline void dofight (int now, int Np) {int End = NP;            if (now! = 1 && p[np].id! = 2) while (1) {if (!usek (Np)) {End = Np;        if (!usek (now)) {End = now; } P[end].    HP--;    int RETP;    if (End = now) Retp = Np;    else Retp = now; if (P[end].        HP = = 0) {if (Recover (End)) return;        P[end].dead = true;        if (p[end].id = = 3) fnum--;        else Znum--;        if (Win ()) return; if (!        Gameover && p[end].id = = 3) Getcard (RETP, 3);     if (p[end].id = = 2 && Retp = = 1) {p[retp].c.clear (); p[retp].cloth = false;}     }}inline bool Fight (int now, int wh) {int Np = 0;         if (now = = 1) {for (int i = now + 1; I <= n; i + +) {   if (p[i].dead) continue; if (P[i].            Isshow && Isfriend (now, i)) continue; if (!p[i].            Isshow &&!think[i]) continue; Np = i;        break; } if (!                NP) for (int i = 1; i < now; i + +) {if (p[i].dead) continue; if (P[i].                Isshow && Isfriend (now, i)) continue; if (!p[i].                Isshow &&!think[i]) continue; Np = i;                break;  }} else if (p[now].id = = 2) {for (int i = now + 1; I <= n; i + +) {if (P[i].dead) continue            ; if (!p[i].            Isshow) continue;            if (Isfriend (now, i)) continue; Np = i;        break; } if (!                NP) for (int i = 1; i < now; i + +) {if (p[i].dead) continue; if (!p[i].                Isshow) continue;                if (Isfriend (now, i)) continue; Np = i;            break;    }} else if (p[now].id = = 3) {    Np = 1; if (!p[now]. isshow) P[now].    Isshow = true; } if (!    NP) return false;    P[now].c.erase (P[now].c.begin () + WH); if (p[np].id = = 2 &&!P[NP].    Isshow) Dofight (now, Np); else if (!    Doj (now, NP)) Dofight (now, NP); return true;}    inline void North (int. now, int wh) {p[now].c.erase (P[now].c.begin () + WH);        for (int i = now + 1; I <= n; i + +) {if (p[i].dead) continue; if (!            Doj (now, i)) {if (Usek (i)) continue; else {P[i].                HP--;                if (p[i].id = = 1) Think[now] = true; if (P[i].                    HP = = 0) {if (Recover (i)) continue;                    P[i].dead = true;                    if (p[i].id = = 3) fnum--;                    else Znum--;                    if (Win ()) return; if (!                    Gameover && p[i].id = = 3) Getcard (now, 3); if (p[i].id = = 2 && now = = 1) {P[noW].c.clear (); P[now].cloth = false;        }}}}} for (int i = 1; i < now; i + +) {if (p[i].dead) continue; if (!            Doj (now, i)) {if (Usek (i)) continue; else {P[i].                HP--;                if (p[i].id = = 1) Think[now] = true; if (P[i].                    HP = = 0) {if (Recover (i)) continue;                    P[i].dead = true;                    if (p[i].id = = 3) fnum--;                    else Znum--;                    if (Win ()) return; if (!                    Gameover && p[i].id = = 3) Getcard (now, 3);                if (p[i].id = = 2 && now = = 1) {p[now].c.clear (); p[now].cloth = false;}    }}}}}inline void Wjqf (int now, int wh) {p[now].c.erase (P[now].c.begin () + WH);        for (int i = now + 1; I <= n; i + +) {if (p[i].dead) continue; if (! Doj (now, i)) {           if (Miss (i)) continue; else {P[i].                HP--;                if (p[i].id = = 1) Think[now] = true; if (P[i].                    HP = = 0) {if (Recover (i)) continue;                    P[i].dead = true;                    if (p[i].id = = 3) fnum--;                    else Znum--;                    if (Win ()) return; if (!                    Gameover && p[i].id = = 3) Getcard (now, 3);                if (p[i].id = = 2 && now = = 1) {p[now].c.clear (); p[now].cloth = false;}        }}}} for (int i = 1; i < now; i + +) {if (p[i].dead) continue; if (!            Doj (now, i)) {if (Miss (i)) continue; else {P[i].                HP--;                if (p[i].id = = 1) Think[now] = true; if (P[i].                    HP = = 0) {if (Recover (i)) continue;                    P[i].dead = true; IF (p[i].id = = 3) fnum--;                    else Znum--;                    if (Win ()) return; if (!                    Gameover && p[i].id = = 3) Getcard (now, 3);                if (p[i].id = = 2 && now = = 1) {p[now].c.clear (); p[now].cloth = false;}    }}}}}inline void Solve (int now) {bool Can = true;    BOOL Killuse = false;        while (CAN) {can = false;        if (Win ()) return;            for (int i = 0; i < p[now].c.size (); i + +) {if (Win ()) return;            if (P[now].dead) return;            char ch = p[now].c[i]; if (ch = = ' P ') {if (P[now]. HP < 4) {P[now].                     HP + +;                     P[now].c.erase (P[now].c.begin () + i); Can = true;                 break; }} else if (ch = = ' K ') {if (Killuse = = True && P[now].cloth = = False) Continu E ;                     if (Kill (now, i)) {Can = true; Killuse = true;                 break;                    }} else if (ch = = ' F ') {if (Fight (now, i)) {Can = true;                break;                 }} else if (ch = = ' N ') {North (now, I);                 Can = true;             break;                 } else if (ch = = ' W ') {WJQF (now, i);                 Can = true;             break; } else if (ch = = ' Z ') {P[now].cloth = true;                 Can = true; P[now].c.erase (P[now].c.begin () + i);             break;    }}}}int Main () {scanf ("%d%d", &n,&m); pnum = 1; for (int i = 1; I <= n; i + +) {P[i]. HP = 4; P[i].         Isshow = false; P[i].cloth = false;        P[i].dead = false;        Char s1[5], s[6][5]; scanf ("%s%s%s%s%s", s1,s[1],s[2], S[3],s[4]);        if (s1[0] = = ' M ') p[i].id = 1, znum + +;        else if (s1[0] = = ' Z ') p[i].id = 2, znum + +;        else P[i].id = 3, fnum + +;    for (int j = 1; J <= 4; j + +) P[i].c.push_back (s[j][0]); } P[1].    Isshow = true;        for (int i = 1; I <= m; i + +) {char s[5];        scanf ("%s", s);    Resp[i] = s[0];    } int now = 1; while (!        Gameover) {if (Win ()) break;            while (P[now].dead) {+ + now;        if (now > N) now = 1;        } Getcard (now, 2);        Solve (now);        + + now;    if (now > N) now = 1; } if (P[1].    HP = = 0) printf ("fp\n");    else printf ("mp\n");        for (int i = 1; I <= n; i + +) {if (p[i].dead) printf ("dead\n");            else {for (int j = 0; J < P[i].c.size (); j + +) printf ("%c", P[i].c[j]);        printf ("\ n"); }} return 0;}

[SDOI2010] pig country kill

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.