描述
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+10; using namespace std; using namespace __gnu_cxx; const int N=50005; string a,b,c; map<string,int>q,Q; set<string>p; int main() { int t=0,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]=0; } while(m--) { cin>>a>>b>>c; string ac=a+c; p.insert(ac); q[ac]=1; } 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=0;i<9;i++)cout<<h[i]; cout<<endl; } } return 0; }