Advertisement
a53

John_cu_bitset_aranjat

a53
Dec 29th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. namespace FastRead
  4. {
  5. const int Dim(1e5);
  6. char buff[Dim];
  7. int pos,len;
  8. inline char nc()
  9. {
  10. if(pos==len)
  11. {
  12. pos=0;
  13. len=fread(buff,1,Dim,stdin);
  14. if(!len)
  15. return EOF;
  16. }
  17. return buff[pos++];
  18. }
  19. template<class T> inline void Read(T& x)
  20. {
  21. char ch;
  22. int sgn(1);
  23. while(!isdigit(ch=nc()))
  24. if(ch =='-')
  25. sgn=-1;
  26. x=ch-'0';
  27. while(isdigit(ch=nc()))
  28. x=x*10+(ch-'0');
  29. x*=sgn;
  30. }
  31. }
  32.  
  33. using namespace FastRead;
  34. using namespace std;
  35. using VI = vector<int>;
  36. using VVI = vector<VI>;
  37. using BITSET = bitset<1001>;
  38. using VB = vector<BITSET>;
  39. int n,m,x,mmax,cmax,curr;
  40. VI v;
  41. VVI retin;
  42. VB f1,f2;
  43. unordered_map<int, int> mp;
  44.  
  45. int main()
  46. {
  47. Read(n),Read(m);
  48. retin=VVI(n+1,VI(m));
  49. for(int i=1;i<=n;++i)
  50. for(int& x:retin[i])
  51. {
  52. Read(x);
  53. v.emplace_back(x);
  54. }
  55. sort(v.begin(),v.end());
  56. v.erase(unique(v.begin(),v.end()),v.end());
  57. for(const int& x:v)
  58. mp[x]=++curr;
  59. f1=VB(curr+1);
  60. f2=VB(n+1);
  61. for(int i=1;i<=n;++i)
  62. for(int& x:retin[i])
  63. {
  64. x=mp[x];
  65. f1[x].set(i);
  66. f2[i].set(x);
  67. }
  68. for(int i=1;i<=curr;++i)
  69. mmax=max(mmax,static_cast<int>(f1[i].count()));
  70. for(int i=1;i<n;++i)
  71. for(int j=i+1;j<=n;++j)
  72. cmax=max(cmax,static_cast<int>((f2[i]&f2[j]).count()));
  73. cout<<mmax<<'\n'<<cmax;
  74. exit(0);
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement