Codeforces gym 100685 A. Ariel 暴力
A. Ariel
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/gym/100685/problem/A
Description
King Triton really likes watching sport competitions on TV. But much more Triton likes watching live competitions. So Triton decides to set up a swimming competition in the kingdom Merfolk. Thousands of creatures come to take part in competition, that's why it is too difficult to take the first place.
For the King's beloved daughter Ariel this competition is the first in her life. Ariel is very kind, so she wants to give a lot of gold medals. Ariel says, that it is unfair to make a single ranking list for creatures that are so different. It is really a good result to be the fastest small fish without tail in Merfolk!
Ariel chooses k important traits (such as size, tailness, rapacity and so on). A creature can either possess a trait or not (there are no intermediate options).
A score is given for each creature (it doesn't matter how it was calculated) and the list of possessed traits f1, ..., fy is also given.
Ariel wants to know the place occupied by creature a in a competition among creatures, who have the same traits h1, ..., ht. So if creature a doesn't have a trait hi, then all creatures in the competition are without this trait. If creature a has a trait hi, then all creatures in the competition have this trait. Other traits doesn't matter. The winner of the competition is a creature with the maximum score.
Input
The first line contains n (1 ≤ n ≤ 104) and k (1 ≤ k ≤ 10). The next n lines contain information about creatures: score (1 ≤ score ≤ 109), y (0 ≤ y ≤ k) — the number of possessed traits, and y numbers fi (1 ≤ fi ≤ k) — ids of possessed traits. All fi in one line are different.
The next line contains m (1 ≤ m ≤ 105) — the number of queries from Ariel. The next m lines describe queries: a (1 ≤ a ≤ n) — the id of a creature, then t — the number of traits, then t numbers hi. All hi in one line are different.
Output
For each query output the place of a creature a in ranking list amount the corresponded creatures. If several creatures have the same score all of them take the same place.
Sample Input
3 2
100 1 1
50 1 2
30 2 1 2
12
1 2 1 2
1 1 1
1 1 2
1 0
2 0
2 1 1
2 1 2
2 2 2 1
3 0
3 2 1 2
3 1 2
3 1 1
Sample Output
1
1
1
1
2
1
1
1
3
1
2
2
HINT
题意
有物种,最多十个特征,并且有分数
然后每次查询,x num hi……hnum
然后问你满足这种特征的生物,这个x的分数排第几
题解:
直接傻逼暴力就好了,不要想多了,出题人是懒的,数据是水的
代码
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 1501
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** vector<int> G[maxn]; struct node
{
int x,y;
};
node kiss[]; int main()
{
int n=read(),k=read();
for(int i=;i<n;i++)
{
kiss[i+].x=read();
int tmp=;
int num=read();
for(int j=;j<num;j++)
{
int x=read();
tmp=tmp|(<<(x-));
}
kiss[i+].y=tmp;
G[tmp].push_back(kiss[i+].x);
}
for(int i=;i<maxn;i++)
sort(G[i].begin(),G[i].end());
int m=read();
for(int i=;i<m;i++)
{
int id=read(),num=read();
int tmp=;
for(int j=;j<num;j++)
{
int x=read();
tmp=tmp|(<<(x-));
}
int ans=;
for(int i=;i<maxn;i++)
if((i&tmp)==(kiss[id].y&tmp))
ans+=G[i].size()-(upper_bound(G[i].begin(),G[i].end(),kiss[id].x)-G[i].begin());
printf("%d\n",ans+);
}
}
Codeforces gym 100685 A. Ariel 暴力的更多相关文章
- Codeforces gym 100685 F. Flood bfs
F. FloodTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/F Desc ...
- Codeforces gym 100685 E. Epic Fail of a Genie 贪心
E. Epic Fail of a GenieTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685 ...
- Codeforces gym 100685 C. Cinderella 水题
C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...
- Codeforces Gym 100015H Hidden Code 暴力
Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hac ...
- Codeforces Gym 100637G G. #TheDress 暴力
G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G ...
- Codeforces Gym 100203G Good elements 暴力乱搞
原题链接:http://codeforces.com/gym/100203/attachments/download/1702/statements.pdf 题解 考虑暴力的复杂度是O(n^3),所以 ...
- Codeforces Gym 101190M Mole Tunnels - 费用流
题目传送门 传送门 题目大意 $m$只鼹鼠有$n$个巢穴,$n - 1$条长度为$1$的通道将它们连通且第$i(i > 1)$个巢穴与第$\left\lfloor \frac{i}{2}\rig ...
- Codeforces Gym 101252D&&floyd判圈算法学习笔记
一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...
- Codeforces Gym 101623A - 动态规划
题目传送门 传送门 题目大意 给定一个长度为$n$的序列,要求划分成最少的段数,然后将这些段排序使得新序列单调不减. 考虑将相邻的相等的数缩成一个数. 假设没有分成了$n$段,考虑最少能够减少多少划分 ...
随机推荐
- button捕捉回车键
为了给一个页面设置回车默认触发的按钮功能,我浏览了IE上的诸多方法,有的言不达意,有的读不懂,后来把高手的一段代码改造后,形成了一段代码,使这个问题的解决变得非常简章,有兴趣的朋友不妨一试.<s ...
- information_schema中的三个关于锁的表
在5.5中,information_schema 库中增加了三个关于锁的表(MEMORY引擎):innodb_trx ## 当前运行的所有事务innodb_locks ## ...
- HTMLayout使用心得
1.关闭按钮 采用CSS!提供的behavior实现窗口关闭功能,不需要在C++代码中处理关闭事件 div { behavior: sys-ctl; -sys-ctl-pos: c ...
- 获取本机外网IP的方式笔记
1.IP138 网址:http://www.ip138.com/: 分离出的快速查询地址:http://20140507.ip138.com/ic.asp(2014年8月9日有效) 个人经验:百度搜索 ...
- [原创]谷歌插件 - YE启动助手(YeLauncher)
版本:v1.1 更新时间:2013/11/01 * 代码完善 + 右键关于显示当前版本号,点击并链接到软件帮助页 版本:v1.0 更新时间:2013/10/20 + 插件原型
- linux挂载问题解决
1. 挂载光盘 </pre></p><p><pre name="code" class="plain">[roo ...
- JQuery WEB前段开发
JQuery WEB前段开发 Jquery是继prototype之后又一个优秀的Javascript框架.它是轻量级的js库 ,它兼容CSS3,还兼容各种浏览器(IE 6.0+, FF 1.5+, S ...
- bzoj 3675 [Apio2014]序列分割(斜率DP)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3675 [题意] 将n个数的序列分割k次,每次的利益为分割后两部分数值和的积,求最大利益 ...
- C#学习1
一.C#可以干什么? 1.桌面应用程序,WinForm 2.Internet应用程序,ASP.Net 3.手机开发,WindowsPhone8 二..Net开发学习路线 C#语言——>简单的Wi ...
- C++11 能好怎?
0. 摘要 近期读了一些关于C++11标准的材料. 本篇博客将从新标准的优点.与旧版本的区别和使用方法三个角度,大致介绍我对C++11的认识. C++11标准,原名C++0x, 是03版旧标准的更新. ...