CF 217 B. Berland Bingo
http://codeforces.com/contest/370/problem/B
题意 :呃,这个题我说不清楚。。。。就是有n个人,第 i 个人手里有 mi 张牌,如果,现在主人念数,念到哪张牌谁就把哪张删掉,最后谁手里没有了谁就赢,如果同时没有了,两个人都输都输出no,最重要的是Write a program that determines whether a player can win the game at the most favorable for him scenario or not.这句话,意思是说每个人都按照每个人想要的哪种方式去念牌,根据样例,第一个人手里有1张牌,是1,第二个人手里有3张牌,分别是2 4 1,第三个人手里2张牌,分别是10和11,按照第一个人想自己赢的方式念牌,应该念1,所以他没有牌了,它可以赢,而对于第二个人来讲,无论怎么念,要么1赢他输,要么两个人全输,而对于第三个人来讲,先念10再念11就可以赢。
思路:这个题,挺坑的。。。。表示交了好几遍呢。。。。这个明白点就是找子集呢,如果第 i 个人手里的牌在第 j 个人手里全有,并且还有别的牌,那么第 i 个人就可以赢,而第 i 个人一定输,所以就是判断子集包含。。。。
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std ;
bool contains(vector<int>a,vector<int>b)//b in a?
{
for(int i = ; i < b.size() ; i++)
{
bool in = false ;
for(int j = ; j < a.size() ; j++)
{
if(a[j] == b[i])
in = true ;
}
if(!in)
return false ;
}
return true ;
}
int main()
{
int n ;
vector<int>a[] ;
while(~scanf("%d",&n))
{
int m,h ;
for(int i = ; i < n ; i++)
{
scanf("%d",&m) ;
a[i].clear() ;
for(int j = ; j < m ; j++)
{
scanf("%d",&h) ;
a[i].push_back(h) ;
}
}
int flag[];
for(int i = ; i < ; i++)
flag[i] = ;
for(int i = ; i < n ; i++)
{
for(int j = ; j < n ; j++)
{
if(i==j) continue;
if(contains(a[j],a[i]))
{
flag[j] = ;
if(a[i].size() == a[j].size())
flag[i] = ;
}
}
}
for(int i = ; i < n ; i++)
if(flag[i]) cout<<"YES"<<endl;
else cout<<"NO"<<endl ;
}
return ;
}
这个是二师兄写的非vector 的
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <string>
#define M 10010
#define INF 1 << 30; using namespace std; int f[][];
int main()
{
int n, i, j, m[M], k, t;
int dp[];
memset(dp , , sizeof(dp));
cin >>n;
for(i = ; i < n; i++)
{
cin >>m[i];
for(j = ; j < m[i]; j++)
cin >>f[i][j];
sort(f[i], f[i]+m[i]);
}
for(i = ; i < n-; i++)
{
for(j = i+; j < n; j++)
{
if(m[i] >= m[j])
{
t = ;
for(k = ; k < m[i]; k++)
{
if(f[i][k] == f[j][t])
t++;
}
if(t >= m[j])
dp[i] = ;
if(m[j] == m[i] && t >= m[j])
dp[j] = ;
}
else
{
t = ;
for(k = ; k < m[j]; k++)
if(f[i][t] == f[j][k])
t++;
if(t >= m[i])
dp[j] = ;
}
}
}
for(i = ; i < n; i++)
{
if(!dp[i])
cout <<"YES"<<endl;
else
cout <<"NO"<<endl;
}
return ;
}
CF 217 B. Berland Bingo的更多相关文章
- CF 370B Berland Bingo
题目链接: 传送门 Berland Bingo time limit per test:1 second memory limit per test:256 megabytes Descrip ...
- cf B. Berland Bingo
http://codeforces.com/contest/370/problem/B 题意:给你n个卡片,卡片上有m个不同的数字,这个游戏是随即的从袋子里面抽球,球上有数字1-100:如果第ith玩 ...
- B. Berland Bingo
Lately, a national version of a bingo game has become very popular in Berland. There are n players p ...
- Edu Cf Round 105 (Div. 2) B. Berland Crossword 1.读懂题, 2. 思维
一. 原题链接 https://codeforces.com/contest/1494/problem/B 二. 题意 + 题解: 没看懂题目, 懵了好久, 先狡辩一下当时误解的句子, 英语是硬伤 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
- [CF1005F]Berland and the Shortest Paths_最短路树_堆优化dij
Berland and the Shortest Paths 题目链接:https://www.codeforces.com/contest/1005/problem/F 数据范围:略. 题解: 太鬼 ...
- ATC/TC/CF
10.25 去打 CF,然后被 CF 打了. CF EDU 75 A. Broken Keyboard 精神恍惚,WA 了一发. B. Binary Palindromes 比赛中的憨憨做法,考虑一个 ...
- CF round #622 (div2)
CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
随机推荐
- 外部div自适应内部标签的高度,设置最小高度、最大高度
一.div自适应高度:在前端开发中经常需要让外层的div自动适应内部标签和内容的高度,内部标签可能是<div>.<ul>.<ol>或者文字等各种内容.造成外层的di ...
- JAXB - Annotations, The Object Factory: XmlRegistry, XmlElementDecl
To be able to create objects from XML elements, the unmarshaller must have an object factory with me ...
- C# is 强制转换
在平时开发中,经常遇上强制转换,在这过程中经常遇上null对象转换为值类型,如果不判断的情况下在编译的时候不会出错,但程序一运行就抛出错误.好在C#为我们提供了is ,它判断一个对象如果成立就转换,如 ...
- Core Animation之CABasicAnimation
在iOS中,图形可分为以下几个层次: 越上层,封装程度越高,动画实现越简洁越简单,但是自由度越低:反之亦然.本文着重介绍Core Animation层的基本动画实现方案. 在iOS中,展示动画可以类比 ...
- 层叠上下文 Stacking Context
层叠上下文 Stacking Context 在CSS2.1规范中,每个盒模型的位置是三维的,分别是平面画布上的x轴,y轴以及表示层叠的z轴.对于每个html元素,都可以通过设置z-index属性来设 ...
- 第10条:始终要覆盖toString
java.lang.Object的toString方法的实现: public String toString() { return getClass().getName() + "@&quo ...
- svn 钩子 post-commit 出现255错误解决办法
首先检查代码中是否有可执行命令 #!/bin/sh 然后 检查post-commit权限 post-commit 脚本文件的权限不对,post-commit 脚本必须有 +x 权限. chown sv ...
- 观【史上最牛linux视频教程】整理笔记,持续更新……
//文件处理命令 命令格式:命令 [-参数] [参数] 例:ls -la /etc -a等于--all //目录处理命令:ls 英文原意:list 所在路径:/bin/ls 语法:ls 选项[-ald ...
- Raphael:JS矢量图形库
Raphael:JS矢量图形库 2016-08-29 http://dmitrybaranovskiy.github.io/raphael/
- winform 通过 html 与swf 交互 简单案例
在上一篇 winform 与 html 交互 简单案例 中讲了winform与html之间的简单交互,接下来的内容是在winform中以html为中转站,实现将swf嵌入winform中并实现交互. ...