Popular Products

时间限制:10000ms
单点时限:1000ms
内存限制:256MB

描述

Given N lists of customer purchase, your task is to find the products that appear in all of the lists.

A purchase list consists of several lines. Each line contains 3 parts: the product id (format XXXX-XXXX), the purchase date (format mm/dd/yyyy) and the price (with decimal places). Two product are considered equal if both the product id and the price are equal.

输入

The first line contains an integer N denoting the number of lists. (1 ≤ N ≤ 1000)

Then follow N blocks. Each block describes one list.

The first line of each block contains an integer M denoting the number of products in the list. (1 ≤ M ≤ 50)

M lines follow. Each line contains the product id, the purchase date and the price.

输出

The products that appear in all of the lists. You should output the product id in increasing order.

If two different product share the same id (with different price) you should output the id twice.

样例输入
3
2
1111-1111 07/23/2016 998.00
1111-2222 07/23/2016 888.00
2
1111-2222 07/23/2016 888.00
1111-1111 07/23/2016 998.00
2
1111-2222 07/23/2016 888.00
1111-1111 07/23/2016 999.00
样例输出
1111-2222
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=1e5+;
using namespace std;
using namespace __gnu_cxx;
const int N=;
string a,b,c;
map<string,int>q,Q;
set<string>p;
int main()
{
int t=,n,m,j,k;
cin>>n;k=n;
while(n--)
{
cin>>m;
for(set<string>::iterator it=p.begin(); it!=p.end(); it++)
{
q[*it]=;
}
while(m--)
{
cin>>a>>b>>c;
string ac=a+c;
p.insert(ac);
q[ac]=;
}
for(set<string>::iterator it=p.begin(); it!=p.end(); it++)
{
Q[*it]+=q[*it];
}
}
for(set<string>::iterator it=p.begin(); it!=p.end(); it++)
{ if(Q[*it]==k)
{
string h=*it;
for(int i=;i<;i++)cout<<h[i];
cout<<endl;
}
}
return ;
}

hihocoder Popular Products(STL)的更多相关文章

  1. Popular Products

    Popular Products 描述 Given N lists of customer purchase, your task is to find the products that appea ...

  2. 【BZOJ2333】棘手的操作(左偏树,STL)

    [BZOJ2333]棘手的操作(左偏树,STL) 题面 BZOJ上看把... 题解 正如这题的题号 我只能\(2333\) 神TM棘手的题目... 前面的单点/联通块操作 很显然是一个左偏树+标记 ( ...

  3. C++标准模板库(STL)之Vector

    在C中,有很多东西需要自己实现.C++提供了标准模板库(Standard Template Libray,STL),其中封装了很多容器,不需要费力去实现它们的细节而直接调用函数来实现功能. 具体容器链 ...

  4. C++标准模板库(STL)和容器

    1.什么是标准模板库(STL)? (1)C++标准模板库与C++标准库的关系 C++标准模板库其实属于C++标准库的一部分,C++标准模板库主要是定义了标准模板的定义与声明,而这些模板主要都是 类模板 ...

  5. 【常用技巧】标准模板库(STL)

    [常用技巧]标准模板库(STL) 在前几个章节中我们已经使用了诸如队列.堆.堆栈.vector 等标准模板库中的模板,切身感受到了它给我们带来的极大便利.在本节中,我们还要介绍两种标准模板——stri ...

  6. [Codeforces 1246B] Power Products (STL+分解质因数)

    [Codeforces 1246B] Power Products (STL+分解质因数) 题面 给出一个长度为\(n\)的序列\(a_i\)和常数k,求有多少个数对\((i,j)\)满足\(a_i ...

  7. C++ 标准模板库(STL)——容器(Containers)的用法及理解

    C++ 标准模板库(STL)中定义了通用的模板类和函数,这些模板类和函数可以实现多种流行和常用的算法和数据结构,如向量(vector).队列(queue).栈(stack).set.map等.这次主要 ...

  8. UVALive 7148 LRIP(树的分治+STL)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  9. 堆的 两种实现 (数组和STL)

    基本思想: 两种操作都跟树的深度成正比,所以复杂度  O(log(n)) ; push():在向堆中插入数值时,首先在堆的末尾插入该数值,然后不断向上提直到没有大小颠倒为止. pop(): 从堆中取出 ...

随机推荐

  1. 停课day1

    一早上只做了一个calculator 还是参照题解,好惭愧 f[1]=0; flag[1]=true;    for (int i=2,N=num[n];i<p;i++) {        fo ...

  2. 【BZOJ 3643】Phi的反函数 数搜索

    这道题是典型的数搜索,讲究把数一层一层化小,而且还有最重要的大质数剪枝. #include <cstdio> #include <cmath> typedef long lon ...

  3. 【NOIP模拟赛】天神下凡 动态开点线段树

    这些圆一定是在同一水平面上的,由于他们没有相交,因此我们发现他们每个人与外界关系可以分为,1.存在并圈圈 2.存在圈圈并被割,因此我们把所有的圆都加1,把被割的在加1,就可以啦,因此我们开一个线段树, ...

  4. Leetcode 45. Jump Game II(贪心)

    45. Jump Game II 题目链接:https://leetcode.com/problems/jump-game-ii/ Description: Given an array of non ...

  5. recycleview的基础Adapter

    .封装了一个基础的adapter.,用于recycleview的快捷使用有BaseAdapter,BaseViewHolder,PAdapter,MainActivity public abstrac ...

  6. Death Note

    注:本文系作者原创,但可随意转载. ********************************************************************************** ...

  7. Linux 安装编译 FFMPEG

    资源准备: ffmpeg-3.4.tar.bz2 yasm-1.3.0.tar.gz 编译安装: 本人二进制包存放在 /opt/moudles中, 解压缩在 /opt/softwares 解包 ffm ...

  8. 【Mysql优化】key和index区别

    mysql的key和index多少有点令人迷惑,这实际上考察对数据库体系结构的了解的.    1).key 是数据库的物理结构,它包含两层意义,一是约束(偏重于约束和规范数据库的结构完整性),二是索引 ...

  9. python3 yield表达式形式应用

    我们已知: 生成器函数:函数体内包含有yield关键字,该函数执行的结果是生成器 yield的功能: 1.与return类似,都可以返回值,但不一样的地方在于yield返回多次值,而return只能返 ...

  10. algorithm ch7 QuickSort

    快速排序是基于分治模式的排序,它将数组a[p,...,r]分成两个子数组a[p,...q-1],a[q+1,...,r],使得a[p,...,q-1]中每个元素都小于a[q],而且小于等于a[q+1, ...