2020 camp-day6-C

Simulation title

On the basis of the rules of the game, let the poison to kill the enemy up to ridicule or blame blame ordinary, ordinary followers to break Divine Shield

          Kills less toxic to break ridicule Divine Shield, Divine Shield or plain strange, strange soldier to a general (not hurt, try not to break Divine Shield)

#include<cstdio>

#define RE register
#define FOR(i,a,b) for(RE int i=a;i<=b;++i)
#define ROF(i,a,b) for(RE int i=a;i>=b;--i)
#define sc(n) scanf("%d",&n)

using namespace std;

const int maxn = 1005;

int n, e, b, c, d, ansx, ansi, T;
int ee, bb, cc, dd;
char s[maxn];

int main()
{
    sc(T);
    while (T--)
    {
        sc(n), sc(e), sc(b), sc(c), sc(d);
        ansx = ansi = 0; bb = b, cc = c, dd = d, ee = e;
        scanf("%s", s + 1);
        FOR(i, 1, n)
        {
            if (s[i] == '1')
            {
                if (c)--c, ++ansx;
                else if (d) --d, ++c;
                else if (e) --e, ++ansx;
                else if (b) --b, ++e;

                if (dd)--dd, ++cc;
                else if (cc)--cc, ++ansi;
                else if (bb) --bb, ++ee;
                else if (ee) --ee, ++ansi;
            }
            else
            {
                if (d) --d, ++c;
                else if (c);
                else if (b) --b, ++e;

                if (cc);
                else if (dd)--dd, ++cc;
            }
        }
        printf("%d %d\n", ansx, ansi);
    }
    return 0;
}
View Code

Guess you like

Origin www.cnblogs.com/2aptx4869/p/12216667.html