HDU 4023 贪心+博弈

/*******************************************************************************
   上海赛区网络赛博弈水题,但是当时最后才A掉,一看那个数据量这么小,肯定枚举一下就行了,具体解法就
是列出对于每块tile,Alice跟Bob分别先放后,两人能得到的分数,然后枚举每块累加一下就完事了~唯一的
trick是对于第一种和第二中tile,需要对两人走的顺序分别考虑,具体看代码就能理解。代码写太搓了,很多
都是粘的。。。
*******************************************************************************/
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

#define LOWBIT(x) ( (x) & ( (x) ^ ( (x) - 1 ) ) )
#define CLR(x, k) memset((x), (k), sizeof(x))
#define CPY(t, s) memcpy((t), (s), sizeof(s))
#define SC(t, s) static_cast(s)
#define LEN(s) static_cast( strlen((s)) )
#define SZ(s) static_cast( (s).size() )

typedef double LF;
typedef __int64 LL;		//VC
typedef unsigned __int64 ULL;

typedef pair PII;
typedef pair PLL;
typedef pair PDD;

typedef vector VI;
typedef vector VC;
typedef vector VF;
typedef vector VS;

template 
T sqa(const T & x)
{
	return x * x;
}
template 
T gcd(T a, T b)
{
	if (!a || !b)
	{
		return max(a, b);
	}
	T t;
	while (t = a % b)
	{
		a = b;
		b = t;
	}
	return b;
};

const int INF_INT = 0x3f3f3f3f;
const LL INF_LL = 0x7fffffffffffffffLL;		//15f
const double oo = 10e9;
const double eps = 10e-7;
const double PI = acos(-1.0);

#define  ONLINE_JUDGE

const int MAXN = 16;

int test, tiles[MAXN];

void ace()
{
	int cas = 1;
	int alice, bob;
	int total;
	for (cin >> test; test--; ++cas)
	{
		CLR(tiles, 0);
		total = 0;
		for (int i = 0; i < 15; ++i)
		{
			cin >> tiles[i];
			total += tiles[i];
		}
		alice = 0;
		bob = 0;
		for (int ind = 0; total > 0; --total, ind ^= 1)
		{
			if (tiles[14] != 0)
			{
				ind ? (alice += 0, bob += 2) : (alice += 2, bob += 0);
				--tiles[14];
			}
			else if (tiles[2] != 0)
			{
				ind ? (alice += 0, bob += 2) : (alice += 1, bob += 0);
				--tiles[2];
			}
			else if (tiles[3] != 0)
			{
				ind ? (alice += 0, bob += 2) : (alice += 1, bob += 0);
				--tiles[3];
			}
			else if (tiles[4] != 0)
			{
				ind ? (alice += 0, bob += 1) : (alice += 2, bob += 0);
				--tiles[4];
			}
			else if (tiles[5] != 0)
			{
				ind ? (alice += 0, bob += 1) : (alice += 2, bob += 0);
				--tiles[5];
			}
			else if (tiles[10] != 0)
			{
				ind ? (alice += 0, bob += 1) : (alice += 1, bob += 0);
				--tiles[10];
			}
			else if (tiles[11] != 0)
			{
				ind ? (alice += 0, bob += 1) : (alice += 1, bob += 0);
				--tiles[11];
			}
			else if (tiles[12] != 0)
			{
				ind ? (alice += 0, bob += 1) : (alice += 1, bob += 0);
				--tiles[12];
			}
			else if (tiles[13] != 0)
			{
				ind ? (alice += 0, bob += 1) : (alice += 1, bob += 0);
				--tiles[13];
			}
			else if (tiles[6] != 0)
			{
				ind ? (alice += 1, bob += 1) : (alice += 1, bob += 0);
				--tiles[6];
			}
			else if (tiles[7] != 0)
			{
				ind ? (alice += 1, bob += 1) : (alice += 1, bob += 0);
				--tiles[7];
			}
			else if (tiles[8] != 0)
			{
				ind ? (alice += 0, bob += 1) : (alice += 1, bob += 1);
				--tiles[8];
			}
			else if (tiles[9] != 0)
			{
				ind ? (alice += 0, bob += 1) : (alice += 1, bob += 1);
				--tiles[9];
			}
			if (ind)	//唯一的trick
			{
				if (tiles[1] != 0)
				{
					ind ? (alice += 0, bob += 2) : (alice += 0, bob += 2);
					--tiles[1];
				}
				else if (tiles[0] != 0)
				{
					ind ? (alice += 2, bob += 0) : (alice += 2, bob += 0);
					--tiles[0];
				}
				
			}
			else
			{
				if (tiles[0] != 0)
				{
					ind ? (alice += 2, bob += 0) : (alice += 2, bob += 0);
					--tiles[0];
				}
				else if (tiles[1] != 0)
				{
					ind ? (alice += 0, bob += 2) : (alice += 0, bob += 2);
					--tiles[1];
				}
			}
		}
		cout << "Case #" << cas << ": ";
		cout << (alice > bob ? "Alice" : "Bob") << endl;
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
#endif
	ace();
	return 0;
}
/*******************************************************************************
Test Data
3
5 4 0 0 0 0 0 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0 0 0 0 0 0
100 100 0 0 0 0 0 0 0 0 0 2 1 0 0
*******************************************************************************/

你可能感兴趣的:(HDU,ACM-杂题,ACM-博弈,网络,oo)