Advertisement
a53

John

a53
Jan 4th, 2021
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using Tvi=vector<int>;
  4. using Tvvi=vector<Tvi>;
  5. using Tbs=bitset<1001>;
  6. using Tvbs=vector<Tbs>;
  7. int n,m,x,NrMaxM,NrMaxC,nre;
  8. Tvi v;
  9. Tvvi A;
  10. Tvbs c1,c2;
  11. unordered_map<int,int> mp;
  12.  
  13. #define DIM 1280000
  14. char buff[DIM];
  15. int poz=0;
  16. void citeste(int &numar) /// Parsarea numerelor naturale
  17. {
  18. numar=0;
  19. while(buff[poz]<'0'||buff[poz]>'9') /// Cat timp caracterul din buffer nu e cifra ignor
  20. if(++poz==DIM) ///daca am "golit" bufferul atunci il umplu
  21. fread(buff,1,DIM,stdin),poz=0;
  22. while('0'<=buff[poz]&&buff[poz]<='9') /// Cat timp dau de o cifra recalculez numarul
  23. {
  24. numar=numar*10+buff[poz]-'0';
  25. if(++poz==DIM)
  26. fread(buff,1,DIM,stdin),poz=0;
  27. }
  28. }
  29.  
  30. int main()
  31. {
  32. citeste(n),citeste(m);
  33. A=Tvvi(n+1,Tvi(m));
  34. for(int i=1;i<=n;++i)
  35. for(int& x:A[i])
  36. citeste(x),v.emplace_back(x);
  37. sort(v.begin(),v.end());
  38. v.erase(unique(v.begin(),v.end()),v.end()); /// Eliminare si stergere duplicate
  39. for(const int& x:v)
  40. mp[x]=++nre;
  41. c1=Tvbs(nre+1);
  42. c2=Tvbs(n+1);
  43. for(int i=1;i<=n;++i)
  44. for(int& x:A[i])
  45. x=mp[x],c1[x].set(i),c2[i].set(x);
  46. for(int i=1;i<=nre;++i)
  47. NrMaxM=max(NrMaxM,static_cast<int>(c1[i].count()));
  48. for(int i=1;i<n;++i)
  49. for(int j=i+1;j<=n;++j)
  50. NrMaxC=max(NrMaxC,static_cast<int>((c2[i]&c2[j]).count()));
  51. cout<<NrMaxM<<'\n'<<NrMaxC;
  52. return 0;
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement