Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning(disable: 4996)
- #pragma comment(linker,"/STACK:64000000")
- #include <iostream>
- #include <sstream>
- #include <stdio.h>
- #include <memory.h>
- #include <algorithm>
- #include <set>
- #include <map>
- #include <string>
- #include <cstring>
- #include <vector>
- #include <cmath>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <cassert>
- #include <time.h>
- #include <bitset>
- using namespace std;
- #define mp make_pair
- #define pb push_back
- #define _(a,b) memset( (a), b, sizeof( a ) )
- #define all(a) a.begin(), a.end()
- #define sz(a) (int)a.size()
- typedef unsigned long long ull;
- typedef long long lint;
- typedef pair < int , int > pii;
- typedef long double ld;
- const int INF = 1000 * 1000 * 1000;
- const lint LINF = 1000000000000000000LL;
- const double eps = 1e-9;
- void prepare(string s)
- {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- #else
- if (sz(s) != 0)
- {
- freopen((s + ".in").c_str(),"r",stdin);
- freopen((s + ".out").c_str(),"w",stdout);
- }
- #endif
- }
- map<pair<string, string>, int> pz;
- map<pair<string, string>, int>::iterator it, itd;
- map<string, int> fling, mling;
- map<string, int>::iterator its;
- string flpi[25], mlpi[25], pname;
- int flpic, mlpic;
- pair <string, string> st;
- int main()
- { int i, j, k, n, u, v;
- prepare("");
- cin >> n;
- for (i=0; i<n; i++)
- {
- cin >> k;
- for (j=0; j<k; j++)
- {
- cin >> pname;
- cin >> flpic;
- for (u=0; u<flpic; u++) cin >> flpi[u];
- cin >> mlpic;
- for (u=0; u<mlpic; u++) cin >> mlpi[u];
- for (u=0; u<flpic; u++)
- {
- its=fling.find(flpi[u]);
- if (its != fling.end()) fling[flpi[u]]++; else fling[flpi[u]]=1;
- for (v=0; v<mlpic; v++)
- {
- its=mling.find(mlpi[v]);
- if (u == 0)
- if (its != mling.end()) mling[mlpi[v]]++; else mling[mlpi[v]]=1;
- st=mp(flpi[u],mlpi[v]);
- it=pz.find(st);
- if (it != pz.end()) pz[st]++;
- else
- {
- its=fling.find(flpi[u]);
- if (its->second == 1) pz[st]=1;
- }
- }
- }
- }
- for (it=pz.begin(); it != pz.end();)
- {
- if ((it->second < fling[it->first.first]) || (it->second != mling[it->first.second]))
- {
- itd=it;
- if (it == pz.begin())
- {
- pz.erase(itd);
- it=pz.begin();
- }
- else
- {
- --it;
- pz.erase(itd);
- }
- }
- else ++it;
- }
- for (it=pz.begin(); it != pz.end(); ++it)
- cout << "(" << it->first.first << ", " << it->first.second << ")\n";
- pz.clear(); fling.clear(); mling.clear();
- if (i < n-1) cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement