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. 辨别 ShopEX Ecshop

    御剑可以识别ShopEX 或者 Ecshop 特征 ShopEX : 蓝色的icon js里有很多Cookie. <link rel="stylesheet" href=&q ...

  2. Python识别网站验证码

    http://drops.wooyun.org/tips/6313 Python识别网站验证码 Manning · 2015/05/28 10:57 0x00 识别涉及技术 验证码识别涉及很多方面的内 ...

  3. hdu_2110_Crisis of HDU(母函数)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2110 题意:给你N个价值和数目,求方案数,很裸的母函数. #include<cstdio> ...

  4. PHP之Zip扩展,解压缩文件,ZipArchive类

    <?php $zip = new ZipArchive();//新建一个对象 /* $zip->open这个方法第一个参数表示处理的zip文件名. 第二个参数表示处理模式,ZipArchi ...

  5. sqlserver 批量修改表前缀

    先把第一句话放到sqlserver查询器中执行一下.然后把查询结果复制出来,进行编辑...一看你就懂了..简单的sql语句拼装 select ' exec sp_rename "' + na ...

  6. php添加gd

    一 GD简介: php处理图形的扩展库,提供了一系列用来处理图片的API.如果开发过程中发现有页面验证码不能显示,则要考虑检查phpinfo(),是否支持GD库. 二 思路: 网上发现添加GD库的方法 ...

  7. make module失败的原因cc1: error: unrecognized command line option “-m64

    cc1: error: unrecognized command line option "-m64"cc1: error: unrecognized command line o ...

  8. Unable to open connection to supplicant on "/data/misc/wifi/sockets/wlan0"

    在调试android wifi UI 的时候,出现了 logcat:  Unable to open connection to supplicant on "/data/misc/wifi ...

  9. go share library

    http://blog.ralch.com/tutorial/golang-sharing-libraries/ Sharing Golang packages to C and Go Sun, Au ...

  10. python 邮件报警

    为了以后方便使用邮件报警 我这边直接写入一推报警模板 方便以后使用 加入模块 import smtplib from email.mime.text import MIMEText from emai ...