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 ...
随机推荐
- shape的使用
android在布局边缘位置处理圆角的两个办法: 1),一个是直接让美工切一张带有圆角的图片. 2),使用shape来解决. 第一种不在赘述,主要讲一下第二中方法来实现. 上边缘出现圆角,下边缘正常的 ...
- Linux防火墙该如何设置
在终端中输入如下命令打开防火墙:chkconfig iptables on如闭防火墙则输入:chkconfig iptables off上述两条命令均要重启系统才能生效.如果不想通过重启系统而即时生效 ...
- ios控件 UILabel
UILabel 的作用是显示文本 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 40)]; lab ...
- 页面跳转后样式丢失js失效
2 页面跳转后样式丢失js失效 问题描述: 用ajax跳转的时候,从a.html跳转到b.html后,b.html的css以及js都失效了. 解决办法: 将当前页面需要用到的css以及js放在< ...
- mac中使用终端生成RSA私钥和公钥文件
1.打开终端输入:cd Desktop/ //进入桌面 2.OpenSSL //打开 OpenSSL 3.生成私钥pem, 执行命令 genrsa -out rsa_private_ke ...
- MJExtension的使用
1. Plist → 模型数组 控制器中引用#import "MJExtension.h" 模型数组 = [模型类名 objectArrayWithFilename:@" ...
- excel中自动变为插入语句的写法
=concatenate("insert into t(b,c) values('",b1,"','",c1,"');")
- Oracle删除死锁进程的方法
本文实例讲述了Oracle删除死锁进程的方法.分享给大家供大家参考.具体如下: 步骤1:用以下SQL查看进程列表,判断出被锁定的表 复制代码代码如下: SELECT dob.OBJECT_NAME T ...
- LNMP环境的安装配置
0.安装必要的依赖软件 如果已经安装了可能会进行升级,版本完全一致则不会进行任何操作. yum -y install bzip2-devel curl-devel freetype-devel gcc ...
- ubuntu 上下载PHP的源代码
参考: https://vpsineu.com/blog/how-to-build-and-install-php-5-6-9-from-source-on-ubuntu-14-04-vps/ 直接 ...