跳到正文

题解

题解:B4227 [常州市程序设计小能手 2024] 游戏

chengjindong约 2 分钟
原文
文章信息与版本

文章信息

发布
2025年4月6日
收录
2025年12月12日
更新
2026年11月18日
篇幅
约 2 分钟
获赞
2
题目
B4227

版本

  1. v1当前

题目

小 H:使最后两个数相同,要把所有个数 <2< 2 的数全部去掉,使其他的数个数都 ≥2\ge 2。

小 Y:使最后两个数不相同,要把所有个数 ≥2\ge 2 的数全部去掉,只剩 11 个,使其他的数个数都 <2< 2。

那么,我们把小 Y 需要去掉的数算出来,记为 ansans。

每个人只能取 n−1n-1 次,那么如果 ans>n−1ans>n-1,小 Y 就取不完了,此时输出 Lose,否则输出 Win。

代码:

C++
#include<bits/stdc++.h>
#define int long long
#define double long double
#define debug(x) cout<<#x<<"->"<<x<<endl<<flush
#define endl '\n'
#define inf INT_MAX 
using namespace std;
const int N=1e7+7;
const int M=1e6+7;
const int mod=1e9+7;
const double eps=1e-6;
signed main(){
	ios::sync_with_stdio(0);
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t;
	cin >>t;
	while(t--){
		int n;
		cin >>n;
		map<int,bool>m;
		int ans=0;
		for(int i=0;i<2*n;i++){
			int x;cin >>x;
			if(m[x])ans++;//之前就有过这个数,数量 >=2,ans 加一
			m[x]=1;//有过这个数了
		}
		if(ans>n-1){//小 Y 取不完,输了
			cout<<"Lose"<<endl;
		}else{//小 H 取不完,赢了
			cout<<"Win"<<endl;
		}
	}
	return 0;
}
原文