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. 【题解】[国家集训队]Crash的数字表格 / JZPTAB

    求解\(\sum_{i = 1}^{n}\sum_{j = 1}^{m}lcm\left ( i,j \right )\). 有\(lcm\left ( i,j \right )=\frac{ij}{ ...

  2. BZOJ4569 [SCOI2016]萌萌哒 【并查集 + 倍增】

    题目链接 BZOJ4569 题解 倍增的思想很棒 题目实际上就是每次让我们合并两个区间对应位置的数,最后的答案\(ans = 9 \times 10^{tot - 1}\),\(tot\)是联通块数, ...

  3. 洛谷 P2893 [USACO08FEB]修路Making the Grade 解题报告

    P2893 [USACO08FEB]修路Making the Grade 题目描述 A straight dirt road connects two fields on FJ's farm, but ...

  4. How to disable index in innodb

    Q: I read from many places that disabling index before loading a data table can significantly speed ...

  5. POJ1984:Navigation Nightmare(带权并查集)

    Navigation Nightmare Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 7871   Accepted: 2 ...

  6. HDU3488:Tour(KM算法)

    Tour Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submis ...

  7. Math.abs为Integer.Min_VALUE返回错误的值

      Math.abs为Integer.Min_VALUE返回错误的值 这段代码: System.out.println(Math.abs(Integer.MIN_VALUE)); 回报-2147483 ...

  8. 7月23号day15总结

    数据清洗完成之后开始编写前端,通过spring框架将清洗后数据库中的数据显示在页面中. 框架的搭建和js的使用都在学习阶段,

  9. javascript中top、clientTop、scrollTop、offsetTop的讲解

    下面结合各上图介绍一下各个属性的作用: 一.offsetTop属性: 此属性可以获取元素的上外缘距离最近采用定位父元素内壁的距离,如果父元素中没有采用定位的,则是获取上外边缘距离文档内壁的距离.所谓的 ...

  10. 入门级:GitHub和Git超超超详细使用教程!

    GitHub和Git入门 考虑到大家以前可能对版本控制工具和Linux命令行工具都不了解,我写了一个简单的博客来让大家学会入门使用方法. GitHub的简单使用 第一步 创建GitHub账号 1. 打 ...