Advertisement
Galebickosikasa

Untitled

May 12th, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
  2. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
  3.  
  4. #include <iostream>
  5. #include <vector>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <random>
  12. #include <chrono>
  13. #include <cassert>
  14. #include <sstream>
  15. #include <fstream>
  16. #include <iomanip>
  17. #include <tuple>
  18. #include <array>
  19.  
  20. #define fi first
  21. #define se second
  22. #define pb push_back
  23. #define ll long long
  24. #define ld long double
  25. #define hm unordered_map
  26. #define pii pair<int, int>
  27. #define sz(a) (int)a.size()
  28. #define all(a) a.begin(), a.end()
  29. #define cinv(v) for (auto& x: v) cin >> x
  30. #define fr(i, n) for (int i = 0; i < (n); ++i)
  31. #define fl(i, l, n) for (int i = (l); i < (n); ++i)
  32.  
  33. #define int ll
  34.  
  35. template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
  36. template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}
  37.  
  38. using namespace std;
  39.  
  40. #ifdef LOCAL
  41. #define dbg(x) cerr << #x << " : " << x << endl
  42. #else
  43. #define dbg(x)
  44. #endif
  45.  
  46. //tg: @runningcherry
  47.  
  48. template <typename Collection> string Join (const Collection& col) {
  49. bool first = true;
  50. stringstream ss;
  51. for (const auto& x: col) {
  52. if (!first) ss << ", ";
  53. first = false;
  54. ss << x;
  55. }
  56. return ss.str ();
  57. }
  58.  
  59. template <typename T1, typename T2> ostream& operator << (ostream& out, const pair<T1, T2>& v) {
  60. return out << '{' << v.fi << ", " << v.se << '}';
  61. }
  62.  
  63. template<typename T> ostream& operator << (ostream& out, const vector<T>& v) {
  64. return out << '[' << Join (v) << ']';
  65. }
  66.  
  67. template <typename T1, typename T2> ostream& operator << (ostream& out, const map<T1, T2>& v) {
  68. return out << '{' << Join (v) << '}';
  69. }
  70.  
  71. template<typename T> ostream& operator << (ostream& out, const set<T>& v) {
  72. return out << '(' << Join (v) << ')';
  73. }
  74.  
  75. template<typename T> ostream& operator << (ostream& out, const multiset<T>& v) {
  76. return out << '(' << Join (v) << ')';
  77. }
  78.  
  79. template <typename T1, typename T2> istream& operator >> (istream& in, pair<T1, T2>& a) {
  80. return in >> a.fi >> a.se;
  81. }
  82.  
  83. const ll inf = (ll) 2e9;
  84. const ll mod = (ll)1e9 + 7;
  85.  
  86. const int maxn = 2e5 + 20;
  87.  
  88. mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  89.  
  90. const int n = 15;
  91. array <array <int, n>, n> goo, dp;
  92. int mx = 0;
  93.  
  94. void dfs (int i, int j) {
  95. fr (jj, n) {
  96. if (goo[i][jj] > goo[i][j]) chkmax (dp[i][j], dp[i][jj] + 1);
  97. }
  98. fr (ii, n) {
  99. if (goo[ii][j] > goo[i][j]) chkmax (dp[i][j], dp[ii][j] + 1);
  100. }
  101. chkmax (dp[i][j], 1);
  102. chkmax (mx, dp[i][j]);
  103. }
  104.  
  105. signed main () {
  106. ios_base::sync_with_stdio (false);
  107. cin.tie (nullptr);
  108. for (auto& v: goo) for (auto& x: v) cin >> x;
  109. vector <vector <int>> a;
  110. fr (i, n) fr (j, n) a.pb ({goo[i][j], i, j});
  111. sort (all (a));
  112. reverse (all (a));
  113.  
  114. for (auto& x: a) dfs (x[1], x[2]);
  115. cout << mx << '\n';
  116.  
  117.  
  118.  
  119.  
  120.  
  121. }
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement