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 ...
随机推荐
- 【转载】Git的安装与使用
Git的安装与使用 转载来源:http://www.cnblogs.com/Bonker/p/3441781.html 1,下载git https://code.google.com/p/msysg ...
- PageView
auto pageview = PageView::create(); pageview->setContentSize(Size(480.0f, 320.0f)); p ...
- 兼容IE6/IE7/IE8/FireFox的css hack
兼容IE6/IE7/IE8/FireFox的css hack .color{ background-color: #CC00FF; background-color: #FF00009; *backg ...
- 高级C#
使用delegates委托写插件方法: public delegate int Transformer (int x); public class Util { public static void ...
- sql 复习
创建表 #设置外键 create table example3(id int primary key, stu_id int, course_id int, constraint c_fk forei ...
- html-----020----事件
html事件 <body> <a href="http://www.cctv.com" accesskey="k" target=" ...
- [LCA & RMQ] [NOIP2013] 货车运输
首先看到这题, 由于要最大, 肯定是求最大生成树 那么 o(n2) dfs 求任意点对之间的最小边是可以想到的 但是看看数据范围肯定TLE 于是暴力出来咯, 不过要注意query的时候判断的时候要 m ...
- Navicat for mysql远程连接数据库详(1130错误解决方法)
用Navicat for mysql连接数据库测试下连接 如果出现1130错误错误代码是1130,ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to ...
- RX学习笔记:在FreeCodeCamp的学习
FreeCodeCamp https://www.freecodecamp.com 2016-07-03 前几日在Github浏览时,偶然看到一个叫FreeCodeCamp的开源项目,进去该网站之后感 ...
- composer php依赖管理工具
#composer是什么 Composer 是 PHP 的一个依赖管理工具.它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们. composer出现之前我们php项目依赖管理大部分都是手动 ...