Popular Products
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的更多相关文章
- hihocoder Popular Products(STL)
Popular Products 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Given N lists of customer purchase, your tas ...
- reactjs入门到实战(十)----one-first_app
index <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <!-- ...
- 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 ...
- 近年Recsys论文
2015年~2017年SIGIR,SIGKDD,ICML三大会议的Recsys论文: [转载请注明出处:https://www.cnblogs.com/shenxiaolin/p/8321722.ht ...
- Comprehensive Guide to build a Recommendation Engine from scratch (in Python) / 从0开始搭建推荐系统
https://www.analyticsvidhya.com/blog/2018/06/comprehensive-guide-recommendation-engine-python/, 一篇详细 ...
- Beyond MySQL --Branching the popular database--转载
原文:http://www.ibm.com/developerworks/library/os-beyondmysql/ Introduction MySQL is one of the most p ...
- 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 ...
- zencart批量设置热卖商品 best seller、点击最高最受欢迎产品 most popular
zencart批量设置某分类下热卖商品数 best seller ; ,,,,,); zencart批量设置某产品点击最高最受欢迎产品 most popular ; ,,,,,);
- 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 ...
随机推荐
- hadoop 及hbase zookeeper 经常出现问题
往往是以下几个 1/ 各节点时间不统一(写shell文件统一时间) 2/配置文件 /etc/hosts文件中ip地址配置错误(更新ip) 3/断网后重启机器 ip地址被修改(更新配置文件中的ip)
- 浅析PageRank算法
很早就对Google的PageRank算法很感兴趣,但一直没有深究,只有个轮廓性的概念.前几天趁团队outing的机会,在动车上看了一些相关的资料(PS:在动车上看看书真是一种享受),趁热打铁,将所看 ...
- MVC中用 BundleCollection 压缩CSS时图片路径问题
MVC中有个专门提供JS和CSS压缩的类,BundleCollection,其实这个类也可以在asp.net中用, 关于BundleCollection类的详细推荐个地址:http://www.cnb ...
- Centos7下安装numpy+matplotlib+scipy
摘自:http://litchiware.github.io/centos/2015/07/05/centos7%E4%B8%8B%E5%AE%89%E8%A3%85numpy+matplotlib+ ...
- js中的clientWidth offsetWidth scrollWidth等的含义
网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...
- Razor Engine,动态脚本语言,mvc上的语法,适用于文件内容生成,静态网页生成等。
https://razorengine.codeplex.com/ 下载并引用:razorengine.dll 代码里这样写,用mvc的人都会!Razor语法! string template = & ...
- Entity Framework Code First ---EF Power Tool 和MySql一起使用遇到的问题
关于如何使用EF Power Tool的介绍请看 http://www.cnblogs.com/LingzhiSun/archive/2011/05/24/EFPowerTool_1.html, 这里 ...
- 漫谈QML
漫谈 QML/Qt Quick QML是从Qt 4.7开始引入的,QML是一种声明语言,使得可以像设计师思考的一样编码,并且Qt Quick元素就是应用程序的编译单元,每一帧的故事板被声明为元素树中的 ...
- rownum使用方法
rownum使用方法: .使用rownum子查询: rownum是一个总是从1开始的伪列,当查询条件rownum)时,不能从数据库查到记录,因此要 通过子查询解决:; 结果: SQL; R ID US ...
- Inno Setup入门(二十一)——Inno Setup类参考(7)
Install Setup 2013-02-02 11:31 378人阅读 评论(0) 收藏 举报 复选框 复选框(CheckBox)用于多个并不互斥的几个选项中作出一个或者多选择,例如字体可以有粗体 ...