Advertisement
a53

John_Of_de_la_Adrian

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