CodeForces - 1162E Thanos Nim (博弈论)

Alice and Bob are playing a game with nn piles of stones. It is guaranteed that nn is an even number. The ii-th pile has aiai stones.

Alice and Bob will play a game alternating turns with Alice going first.

On a player's turn, they must choose exactly n2n2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n2n2 nonempty piles).

Given the starting configuration, determine who will win the game.

Input

The first line contains one integer nn (2n502≤n≤50) — the number of piles. It is guaranteed that nn is an even number.

The second line contains nn integers a1,a2,,ana1,a2,…,an (1ai501≤ai≤50) — the number of stones in the piles.

Output

Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes).

Examples

Input
2
8 8
Output
Bob
Input
4
3 1 4 1
Output
Alice

题意:
给偶数(n)堆石子,每一步必须取n/2堆石子中的任意多个,当场上不足n/2堆石子时,当前玩家失败,问谁是最后的获胜者。
思路:
如果有任何一堆石子已经被拿空,那么只需要直接取空n/2堆石子,便可以获胜。
所以作为后手,如果能维护石子数量最小的堆数量大于N,便可以取胜,因为在这种情况下,石子数越来越少,先手总会拿空一堆。

#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#define fuck(x) cout<<#x<<" = "<<x<<endl;
#define debug(a,i) cout<<#a<<"["<<i<<"] = "<<a[i]<<endl;
#define ls (t<<1)
#define rs ((t<<1)+1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100086;
const int maxm = 100086;
const int inf = 2.1e9;
const ll Inf = 999999999999999999;
const int mod = 1000000007;
const double eps = 1e-6;
const double pi = acos(-1);
int num[maxn];
int main()
{
//    ios::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&num[i]);
    }
    sort(num+1,num+1+n);
    if(num[n/2+1]!=num[1]){printf("Alice\n");}
    else printf("Bob\n");
    return 0;
}
View Code

 

转载于:https://www.cnblogs.com/ZGQblogs/p/10840951.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值