fork download
  1. #include <bits/stdc++.h>
  2. #define pi acos(-1)
  3. #define sz(x) (int) x.size()
  4. #define pii pair<int, int>
  5. #define pill pair<int, long long>
  6. #define mii map<int, int>
  7. #define vi vector<int>
  8. #define vll vector<long long>
  9. #define vs vector<string>
  10. #define vb vector<bool>
  11. #define mp make_pair
  12. #define pb push_back
  13. #define fi first
  14. #define se second
  15. #define popb pop_back
  16. #define all(v) v.begin(),v.end()
  17. #define mset(v, x) memset(v, x, sizeof(v))
  18. #define mset2d(v, x, n) memset(v, x, sizeof(v[0][0]) * n * n)
  19. #define mset2dd(v, x, n, m) memset(v, x, sizeof(v[0][0]) * n * m)
  20. #define debug(x) cerr<<#x<<" : "<<x<<endl
  21. #define debug2(x,y) cerr<<#x<<" : "<<x<<" & "<<#y<<" : "<<y<<endl
  22. #define test() cerr<<"hola papa"<<endl
  23. typedef long long ll;
  24. typedef long double ld;
  25. typedef unsigned long long ull;
  26. using namespace std;
  27.  
  28. int n, t, s;
  29. ll x;
  30.  
  31. int main() {
  32. cin >> n;
  33.  
  34. vector< vll > vl;
  35. vector< vll > vh;
  36.  
  37. map<ll, int> m;
  38. map<ll, int>::iterator it;
  39.  
  40. for (int i = 0; i < n; ++i) {
  41. vll v;
  42. cin >> t >> s;
  43.  
  44. for (int j = 0; j < s; ++j) {
  45. cin >> x;
  46. v.pb(x);
  47. m[x] = 0;
  48. }
  49.  
  50. t == 1 ? vl.pb(v) : vh.pb(v);
  51. }
  52.  
  53. for (int i = 0; i < sz(vl); ++i) {
  54. for (int j = 0; j < sz(vl[i]); ++j) {
  55. m[vl[i][j]]++;
  56. }
  57. }
  58.  
  59. for (int i = 0; i < sz(vh); ++i) {
  60. for (int j = 0; j < sz(vh[j]); ++j) {
  61. m[vh[i][j]] = -1;
  62. }
  63. }
  64.  
  65. int ans = 0;
  66.  
  67. for (it = m.begin(); it != m.end(); ++it) {
  68. if (it->se == sz(vl)) {
  69. ++ans;
  70. }
  71. }
  72.  
  73. cout << ans << "\n";
  74. }
  75.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
0