Popular Products

描述

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
分析:数据可以用map存储,小心模拟,输出有序;
代码:
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cstring>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const int maxn=3e4+;
using namespace std;
int n,m;
map<pair<string,string>,int>p;
vector<string>ans;
string a,b,c;
int main()
{
int i,j,k,t;
scanf("%d",&n);
rep(i,,n)
{
scanf("%d",&m);
while(m--)
{
cin>>a>>b>>c;
if(p[mp(a,c)]==i-)p[mp(a,c)]++;
if(p[mp(a,c)]==n)ans.pb(a),p[mp(a,c)]=;
}
}
sort(ans.begin(),ans.end());
for(string x:ans)cout<<x<<endl;
//system("pause");
return ;
}

Popular Products的更多相关文章

  1. hihocoder Popular Products(STL)

    Popular Products 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Given N lists of customer purchase, your tas ...

  2. reactjs入门到实战(十)----one-first_app

    index <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <!-- ...

  3. DTrace to Troubleshoot Java Native Memory Problems

    How to Use DTrace to Troubleshoot Java Native Memory Problems on Oracle Solaris 11 Hands-On Labs of ...

  4. 近年Recsys论文

    2015年~2017年SIGIR,SIGKDD,ICML三大会议的Recsys论文: [转载请注明出处:https://www.cnblogs.com/shenxiaolin/p/8321722.ht ...

  5. Comprehensive Guide to build a Recommendation Engine from scratch (in Python) / 从0开始搭建推荐系统

    https://www.analyticsvidhya.com/blog/2018/06/comprehensive-guide-recommendation-engine-python/, 一篇详细 ...

  6. Beyond MySQL --Branching the popular database--转载

    原文:http://www.ibm.com/developerworks/library/os-beyondmysql/ Introduction MySQL is one of the most p ...

  7. Fulfilling Work: The Shippers More entrepreneurs hire 'fulfillment' outfits to store and ship their products

    By Stu Woo June 23, 2011 Brett Teper faced a logistical problem when he and a partner founded ModPro ...

  8. zencart批量设置热卖商品 best seller、点击最高最受欢迎产品 most popular

    zencart批量设置某分类下热卖商品数 best seller ; ,,,,,); zencart批量设置某产品点击最高最受欢迎产品 most popular ; ,,,,,);

  9. Vacuum Pump Manufacturer - Vacuum Pump: Prevents Reactive Compound Decomposition Products

    Vacuum packaging has been popular in the industry for a long time. Many large companies have joined ...

随机推荐

  1. SMO 的环境

    Microsoft SQL Server System CLR Types - http://go.microsoft.com/fwlink/?LinkId=123721&clcid=0x40 ...

  2. VBS调用windows api函数(postmessage)实现后台发送按键脚本

    '=========================================================================='' VBScript Source File - ...

  3. php 上传缩放图片

    有时上传图片时因为图片太大了,不仅占用空间,消耗流量,而且影响浏(图片的尺寸大小不一).下面分享一种等比例不失真缩放图片的方法,这样,不管上传的图片尺有多大,都会自动压缩到我们设置尺寸值的范围之内.经 ...

  4. 第四十三节,文件、文件夹、压缩包、处理模块shutil

    文件.文件夹.压缩包.处理模块shutil 文件处理 copyfileobj()模块函数 功能:将a文件的内容,复制到b文件中[有参] 使用方法:模块名称.copyfileobj(poen(" ...

  5. ADT(abstract data types)抽象数据类型

    1.What is it? An abstract data type is a set of objects together with a set of operations. 抽象数据类型是带有 ...

  6. qmake pro工程设置

    ----我的生活,我的点点滴滴!! #以下是在terminal里面编译,想编译哪个就修改pro文件 #================================================= ...

  7. Mysql找回root密码

    1.停止数据库服务 service mysql stop 2.修改my.cnf 添加skip-grant-tables 3.重启数据库 service mysql restart 4.修改root密码 ...

  8. Inno Setup入门(十二)——Pascal脚本(1)

    事件函数(1) Inno Setup支持以下函数和过程. function InitializeSetup(): Boolean; 该函数在安装程序初始化时调用,返回False 将中断安装,True则 ...

  9. gre tunnel

    http://searchenterprisewan.techtarget.com/tip/GRE-tunnel-vs-IPsec-tunnel-What-is-the-difference Enca ...

  10. ios屏幕

    设备 屏幕尺寸 分辨率(pt) Reader 分辨率(px) 渲染后 PPI iPhone 3GS 3.5吋 320x480 @1x 320x480   163 iPhone 4/4s 3.5吋 32 ...