{"id":377758,"date":"2024-06-01T15:05:52","date_gmt":"2024-06-01T15:05:52","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=377758"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-01T15:05:52","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=377758","title":{"rendered":"<span>Time Limit Exceeded \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0425\u0430\u0431\u0440\u0430!<\/p>\n<p><em>Disclaimer: \u042f \u043d\u0435 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e Senior \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 C\/C++ \u0438 \u043d\u0435 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u043b ICPC. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0443 \u043a\u043e\u0434 \u043d\u0430 Golang \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0430\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438. \u0418 \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e!<\/em><\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/strong><\/p>\n<p>\u0412\u0447\u0435\u0440\u0430 \u044f \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u0448\u0435\u043b \u043d\u0430 Leetcode, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u0443\u044e <a href=\"https:\/\/leetcode.com\/problems\/student-attendance-record-ii\/description\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u0434\u0430\u0447\u043a\u0443<\/a>. \u0423\u0441\u043b\u043e\u0432\u0438\u0435: <\/p>\n<pre><code>An attendance record for a student can be represented as a string  where each character signifies whether the student was absent, late, or present on that day.  The record only contains the following three characters:  'A': Absent.  'L': Late.  'P': Present.  Any student is eligible for an attendance award if they meet\u00a0both\u00a0of the following criteria:  The student was absent ('A') for\u00a0strictly\u00a0fewer than 2 days\u00a0total.  The student was\u00a0never\u00a0late ('L') for 3 or more\u00a0consecutive\u00a0days.  Given an integer\u00a0n, return\u00a0the\u00a0number\u00a0of possible attendance records of length\u00a0n\u00a0that make a student eligible for an attendance award. The answer may be very large, so return it\u00a0modulo\u00a0109 + 7<\/code><\/pre>\n<p>\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043a\u043e\u0434, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u0432\u0441\u0435 \u043e\u043a. \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e <code>Time Limit Exceeded<\/code>. \u041f\u043e\u0441\u0438\u0434\u0435\u0432 \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u0432 \u0435\u0449\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0448\u0435. \u041f\u043e\u0448\u0435\u043b \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 <a href=\"https:\/\/leetcode.com\/problems\/student-attendance-record-ii\/solutions\/5208683\/going-from-brute-to-optimal\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/a>. \u0417\u0434\u0435\u0441\u044c \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u0438\u0448\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u043d\u043e \u043e\u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041e\u043d \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0434 \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>\u041c\u043e\u0435 (TLE):<\/p>\n<pre><code>class Solution { public:     int mod = 1e9+7;      int checkRecord(int n) {         map&lt;tuple&lt;int,int,int>, int> memo;         return helper(n, 0, 0, memo);     }      int helper(int n, int absence, int consLate, map&lt;tuple&lt;int,int,int>,int>&amp; memo) {         if (n == 0) return 1;         if (memo.find({n, absence, consLate}) != memo.end()) return memo[{n,absence, consLate}];          int result = 0;         result = (result + helper(n-1, absence, 0, memo)) % mod;         if (absence &lt; 1) {             result = (result + helper(n-1, absence+1, 0, memo)) % mod;         }         if (consLate &lt; 2) {             result = (result + helper(n-1, absence, consLate+1, memo)) % mod;         }          memo[{n,absence, consLate}] = result;         return result;     } }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code>class Solution { private:     static const int MOD = 1000000000 + 7;  public:     int checkRecord(int n) {         vector&lt;vector&lt;int>> prevDP(2, vector&lt;int>(3, 1));          for (int i = 1; i &lt;= n; i++) {             vector&lt;vector&lt;int>> newDP(2, vector&lt;int>(3, 0));             for (int a = 0; a &lt; 2; a++) {                 for (int l = 0; l &lt; 3; l++) {                     \/\/ Pick P                     newDP[a][l] += prevDP[a][2];                     newDP[a][l] %= MOD;                     if (a > 0) {                         \/\/ Pick A                         newDP[a][l] += prevDP[a - 1][2];                         newDP[a][l] %= MOD;                     }                     if (l > 0) {                         \/\/ Pick L                         newDP[a][l] += prevDP[a][l - 1];                         newDP[a][l] %= MOD;                     }                 }             }             prevDP = newDP;         }          return prevDP[1][2];     } };<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0430\u043a \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0443 \u043d\u0438\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430\u044f O(n), \u0442\u043e \u0435\u0441\u0442\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f. \u0422\u0443\u0442 \u044f \u0438 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u0435\u0435.<\/p>\n<p><strong>\u041f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong><\/p>\n<p>\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 100 \u0440\u0430\u0437 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e \u043e\u0431\u044a\u0435\u043c\u0443 \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u041f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u044f \u0434\u0435\u043b\u0430\u043b \u043d\u0430 Windows (\u043a\u0430\u044e\u0441\u044c) \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 gprof. \u041f\u0440\u043e\u0444\u0438\u043b\u044c \u043c\u043e\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0432\u044b\u0434\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u0430\u043c\u043e\u0433\u043e gprof:<\/p>\n<pre><code>  2.03     27.47     0.66 505560900     0.00     0.00  std::__tuple_compare&lt;std::tuple&lt;int, int, int>, std::tuple&lt;int, int, int>, 0ull, 3ull>::__less(std::tuple&lt;int, int, int> const&amp;, std::tuple&lt;int, int, int> const&amp;)   1.57     27.98     0.51 1338627000     0.00     0.00  std::tuple_element&lt;0ull, std::tuple&lt;int, int, int> >::type const&amp; std::get&lt;0ull, int, int, int>(std::tuple&lt;int, int, int> const&amp;)   1.26     28.39     0.41 1338627000     0.00     0.00  std::_Head_base&lt;0ull, int, false>::_M_head(std::_Head_base&lt;0ull, int, false> const&amp;)   1.08     28.74     0.35 1338627000     0.00     0.00  int const&amp; std::__get_helper&lt;0ull, int, int, int>(std::_Tuple_impl&lt;0ull, int, int, int> const&amp;)<\/code><\/pre>\n<p>\u0421\u0430\u043c \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u043e\u043a\u043e\u043b\u043e 32 \u0441\u0435\u043a\u0443\u043d\u0434, \u0432 \u0442\u043e\u043f\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0438\u0434\u0438\u043c \u043d\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0445 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0439, \u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 tuple, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u043a map, \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 tuple.<\/p>\n<p>\u041f\u0440\u043e\u0444\u0438\u043b\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u044b\u0434\u0430\u043b \u0447\u0442\u043e-\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code>  1.63      1.10     0.02  1000100     0.00     0.00  std::vector&lt;int, std::allocator&lt;int> >* std::__do_uninit_fill_n&lt;std::vector&lt;int, std::allocator&lt;int> >*, unsigned long long, std::vector&lt;int, std::allocator&lt;int> > >(std::vector&lt;int, std::allocator&lt;int> >*, unsigned long long, std::vector&lt;int, std::allocator&lt;int> > const&amp;)   0.81      1.11     0.01 12000600     0.00     0.00  __gnu_cxx::__normal_iterator&lt;int const*, std::vector&lt;int, std::allocator&lt;int> > >::base() const   0.81      1.12     0.01  9000000     0.00     0.00  __gnu_cxx::__normal_iterator&lt;int*, std::vector&lt;int, std::allocator&lt;int> > >::__normal_iterator(int* const&amp;)<\/code><\/pre>\n<p>\u0418 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u043e\u043a\u043e\u043b\u043e \u043e\u0434\u043d\u043e\u0439 \u0441 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044c\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>\u0420\u0430\u0437 \u0442\u0430\u043a\u043e\u0435 \u0434\u0435\u043b\u043e, \u044f \u0440\u0435\u0448\u0438\u043b \u0443\u0431\u0440\u0430\u0442\u044c tuple \u0438\u0437 \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043e\u0434\u0430. \u042f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u044d\u0442\u043e\u0442 tuple \u0432 \u0432\u0438\u0434\u0435 int, \u0441\u0447\u0438\u0442\u0430\u044f, \u0447\u0442\u043e tuple \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, <code>tuple(i, j, k) = i*6 + j*3 + k.<\/code> \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f 6 \u0438 3 \u0432\u044b\u0445\u043e\u0434\u044f\u0442 \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 tuple \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0439\u0442\u0438. \u0414\u0435\u043b\u0430\u044e \u043f\u0440\u043e\u0444\u0438\u043b\u044c, \u043f\u043e\u043b\u0443\u0447\u0430\u044e:<\/p>\n<pre><code>  2.40      9.72     0.27 505560900     0.00     0.00  std::less&lt;int>::operator()(int const&amp;, int const&amp;) const   2.32      9.98     0.26 25994400     0.00      0.00  std::_Rb_tree&lt;int, std::pair&lt;int const, int>, std::_Select1st&lt;std::pair&lt;int const, int> >, std::less&lt;int>, std::allocator&lt;std::pair&lt;int const, int> > >::_M_lower_bound(std::_Rb_tree_node&lt;std::pair&lt;int const, int> >*, std::_Rb_tree_node_base*, int const&amp;)   1.51     10.15     0.17 503228700     0.00     0.00  std::_Rb_tree&lt;int, std::pair&lt;int const, int>, std::_Select1st&lt;std::pair&lt;int const, int> >, std::less&lt;int>, std::allocator&lt;std::pair&lt;int const, int> > >::_S_key(std::_Rb_tree_node&lt;std::pair&lt;int const, int> > const*)   1.42     10.31     0.16 503228700     0.00     0.00  std::_Rb_tree_node&lt;std::pair&lt;int const, int> >::_M_valptr() const   1.25     10.45     0.14 503228700     0.00     0.00  __gnu_cxx::__aligned_membuf&lt;std::pair&lt;int const, int> >::_M_ptr() const<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u0434\u0435\u0440\u0435\u0432\u044c\u044f. \u041f\u043e\u0433\u0443\u0433\u043b\u0438\u0432, \u044f \u0443\u0437\u043d\u0430\u043b, \u0447\u0442\u043e map \u0432 C++ &#8212; \u044d\u0442\u043e \u0434\u0435\u0440\u0435\u0432\u043e, \u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e unordered_map (\u043f\u0440\u0430\u0432\u0434\u0430 \u0441\u0434\u0435\u043b\u0430\u043b \u044f \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f). \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0435\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u044b\u043b\u0430 O(n*logn), \u0430 \u043d\u0435 O(n).<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u0437\u0430\u043c\u0435\u043d\u0438\u043b map \u043d\u0430 unordered_map, \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0430\u043b\u0430 O(n). \u0422.\u043a. \u044d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 std::hash \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u044d\u0448\u0430, \u0432\u0435\u0440\u043d\u0443\u0442\u044c tuple \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e int. \u0414\u0435\u043b\u0430\u044e \u043f\u0440\u043e\u0444\u0438\u043b\u044c:<\/p>\n<pre><code>  2.17      2.47     0.07 25554600     0.00     0.00  std::__detail::_Hash_node&lt;std::pair&lt;int const, int>, false>::_M_next() const   1.55      2.52     0.05 24994400     0.00     0.00  std::_Hashtable&lt;int, std::pair&lt;int const, int>, std::allocator&lt;std::pair&lt;int const, int> >, std::__detail::_Select1st, std::equal_to&lt;int>, std::hash&lt;int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits&lt;false, false, true> >::_M_find_before_node(unsigned long long, int const&amp;, unsigned long long) const   1.55      2.57     0.05      100     0.50     7.74  helper(int, int, int, std::unordered_map&lt;int, int, std::hash&lt;int>, std::equal_to&lt;int>, std::allocator&lt;std::pair&lt;int const, int> > >&amp;)<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 std::hash, \u043d\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c. \u041d\u0443\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0417\u043d\u0430\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u0430\u043f\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440. \u0422\u0430\u043a \u043a\u0430\u043a \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u044d\u0442\u043e O(1) \u0438 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u043e \u0441\u0434\u0432\u0438\u0433\u043e\u043c, \u0442\u043e \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434.<\/p>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u043b \u043c\u0430\u043f\u0443 \u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440, \u0432\u044b\u0434\u0435\u043b\u0438\u0432 \u0435\u043c\u0443 (1e6+1)*6 \u0438\u043d\u0442\u043e\u0432. \u0414\u0435\u043b\u0430\u044e \u043f\u0440\u043e\u0444\u0438\u043b\u044c, \u043f\u043e\u043b\u0443\u0447\u0430\u044e:<\/p>\n<pre><code>100.00      0.01     0.01      100   100.00   100.00  __gnu_cxx::__enable_if&lt;std::__is_scalar&lt;int>::__value, void>::__type std::__fill_a1&lt;int*, int>(int*, int*, int const&amp;)   0.00      0.01     0.00      300     0.00     0.00  std::__new_allocator&lt;int>::~__new_allocator()   0.00      0.01     0.00      200     0.00     0.00  std::__new_allocator&lt;int>::_M_max_size() const   0.00      0.01     0.00      200     0.00     0.00  std::allocator&lt;int>::~allocator()<\/code><\/pre>\n<p>\u0412\u0443\u0430\u043b\u044f, \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0449\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c.<\/p>\n<p><strong>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/strong><\/p>\n<p>\u0427\u0442\u043e \u044f \u0445\u043e\u0442\u0435\u043b \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439. \u042f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u0430\u043c\u0438 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0432\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0443\u0442, \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0441\u043e \u043c\u043d\u043e\u0439 \u043d\u0430 Leetcode. \u0412\u0435\u0434\u044c \u043f\u043e \u0441\u0443\u0442\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0430 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0430\u043c\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f? \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0412\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0431\u044b. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0447\u0435\u043c \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<p>\u0418 \u0432 \u0437\u0430\u0449\u0438\u0442\u0443 \u0441\u0435\u0431\u044f \u043e\u0442 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0445\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044f \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0432\u044b\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0441\u0432\u043e\u044e \u043e\u0431\u0438\u0434\u0443 \u0438\u043b\u0438 \u043d\u0430\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c\u0441\u044f \ud83d\ude42<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u044e\u0441\u044c \u0441\u0432\u043e\u0438\u043c \u0442\u0430\u043a\u0438\u043c \u0432\u043e\u0442 \u043e\u043f\u044b\u0442\u043e\u043c.<\/p>\n<p><em>P.S. \u042d\u0442\u043e\u0439 \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044f \u043d\u0435 \u0434\u043e\u0433\u043b\u044f\u0434\u0435\u043b (\u043f\u0435\u0440\u0435\u0434\u0430\u043b \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0430 \u043d\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435) \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043b.<\/em><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/817501\/\"> https:\/\/habr.com\/ru\/articles\/817501\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0425\u0430\u0431\u0440\u0430!<\/p>\n<p><em>Disclaimer: \u042f \u043d\u0435 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e Senior \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 C\/C++ \u0438 \u043d\u0435 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u043b ICPC. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0443 \u043a\u043e\u0434 \u043d\u0430 Golang \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0430\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438. \u0418 \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e!<\/em><\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/strong><\/p>\n<p>\u0412\u0447\u0435\u0440\u0430 \u044f \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u0448\u0435\u043b \u043d\u0430 Leetcode, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u0443\u044e <a href=\"https:\/\/leetcode.com\/problems\/student-attendance-record-ii\/description\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u0434\u0430\u0447\u043a\u0443<\/a>. \u0423\u0441\u043b\u043e\u0432\u0438\u0435: <\/p>\n<pre><code>An attendance record for a student can be represented as a string  where each character signifies whether the student was absent, late, or present on that day.  The record only contains the following three characters:  'A': Absent.  'L': Late.  'P': Present.  Any student is eligible for an attendance award if they meet\u00a0both\u00a0of the following criteria:  The student was absent ('A') for\u00a0strictly\u00a0fewer than 2 days\u00a0total.  The student was\u00a0never\u00a0late ('L') for 3 or more\u00a0consecutive\u00a0days.  Given an integer\u00a0n, return\u00a0the\u00a0number\u00a0of possible attendance records of length\u00a0n\u00a0that make a student eligible for an attendance award. The answer may be very large, so return it\u00a0modulo\u00a0109 + 7<\/code><\/pre>\n<p>\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043a\u043e\u0434, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u0432\u0441\u0435 \u043e\u043a. \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e <code>Time Limit Exceeded<\/code>. \u041f\u043e\u0441\u0438\u0434\u0435\u0432 \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u0432 \u0435\u0449\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0448\u0435. \u041f\u043e\u0448\u0435\u043b \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 <a href=\"https:\/\/leetcode.com\/problems\/student-attendance-record-ii\/solutions\/5208683\/going-from-brute-to-optimal\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/a>. \u0417\u0434\u0435\u0441\u044c \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u0438\u0448\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u043d\u043e \u043e\u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041e\u043d \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0434 \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<p>\u041c\u043e\u0435 (TLE):<\/p>\n<pre><code>class Solution { public:     int mod = 1e9+7;      int checkRecord(int n) {         map&lt;tuple&lt;int,int,int>, int> memo;         return helper(n, 0, 0, memo);     }      int helper(int n, int absence, int consLate, map&lt;tuple&lt;int,int,int>,int>&amp; memo) {         if (n == 0) return 1;         if (memo.find({n, absence, consLate}) != memo.end()) return memo[{n,absence, consLate}];          int result = 0;         result = (result + helper(n-1, absence, 0, memo)) % mod;         if (absence &lt; 1) {             result = (result + helper(n-1, absence+1, 0, memo)) % mod;         }         if (consLate &lt; 2) {             result = (result + helper(n-1, absence, consLate+1, memo)) % mod;         }          memo[{n,absence, consLate}] = result;         return result;     } }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code>class Solution { private:     static const int MOD = 1000000000 + 7;  public:     int checkRecord(int n) {         vector&lt;vector&lt;int>> prevDP(2, vector&lt;int>(3, 1));          for (int i = 1; i &lt;= n; i++) {             vector&lt;vector&lt;int>> newDP(2, vector&lt;int>(3, 0));             for (int a = 0; a &lt; 2; a++) {                 for (int l = 0; l &lt; 3; l++) {                     \/\/ Pick P                     newDP[a][l] += prevDP[a][2];                     newDP[a][l] %= MOD;                     if (a > 0) {                         \/\/ Pick A                         newDP[a][l] += prevDP[a - 1][2];                         newDP[a][l] %= MOD;                     }                     if (l > 0) {                         \/\/ Pick L                         newDP[a][l] += prevDP[a][l - 1];                         newDP[a][l] %= MOD;                     }                 }             }             prevDP = newDP;         }          return prevDP[1][2];     } };<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0430\u043a \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0443 \u043d\u0438\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430\u044f O(n), \u0442\u043e \u0435\u0441\u0442\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f. \u0422\u0443\u0442 \u044f \u0438 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u0435\u0435.<\/p>\n<p><strong>\u041f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong><\/p>\n<p>\u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 100 \u0440\u0430\u0437 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e \u043e\u0431\u044a\u0435\u043c\u0443 \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>\u041f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u044f \u0434\u0435\u043b\u0430\u043b \u043d\u0430 Windows (\u043a\u0430\u044e\u0441\u044c) \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 gprof. \u041f\u0440\u043e\u0444\u0438\u043b\u044c \u043c\u043e\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0432\u044b\u0434\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u0430\u043c\u043e\u0433\u043e gprof:<\/p>\n<pre><code>  2.03     27.47     0.66 505560900     0.00     0.00  std::__tuple_compare&lt;std::tuple&lt;int, int, int>, std::tuple&lt;int, int, int>, 0ull, 3ull>::__less(std::tuple&lt;int, int, int> const&amp;, std::tuple&lt;int, int, int> const&amp;)   1.57     27.98     0.51 1338627000     0.00     0.00  std::tuple_element&lt;0ull, std::tuple&lt;int, int, int> >::type const&amp; std::get&lt;0ull, int, int, int>(std::tuple&lt;int, int, int> const&amp;)   1.26     28.39     0.41 1338627000     0.00     0.00  std::_Head_base&lt;0ull, int, false>::_M_head(std::_Head_base&lt;0ull, int, false> const&amp;)   1.08     28.74     0.35 1338627000     0.00     0.00  int const&amp; std::__get_helper&lt;0ull, int, int, int>(std::_Tuple_impl&lt;0ull, int, int, int> const&amp;)<\/code><\/pre>\n<p>\u0421\u0430\u043c \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u043e\u043a\u043e\u043b\u043e 32 \u0441\u0435\u043a\u0443\u043d\u0434, \u0432 \u0442\u043e\u043f\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0438\u0434\u0438\u043c \u043d\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0445 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0439, \u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 tuple, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u043a map, \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 tuple.<\/p>\n<p>\u041f\u0440\u043e\u0444\u0438\u043b\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u044b\u0434\u0430\u043b \u0447\u0442\u043e-\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code>  1.63      1.10     0.02  1000100     0.00     0.00  std::vector&lt;int, std::allocator&lt;int> >* std::__do_uninit_fill_n&lt;std::vector&lt;int, std::allocator&lt;int> >*, unsigned long long, std::vector&lt;int, std::allocator&lt;int> > >(std::vector&lt;int, std::allocator&lt;int> >*, unsigned long long, std::vector&lt;int, std::allocator&lt;int> > const&amp;)   0.81      1.11     0.01 12000600     0.00     0.00  __gnu_cxx::__normal_iterator&lt;int const*, std::vector&lt;int, std::allocator&lt;int> > >::base() const   0.81      1.12     0.01  9000000     0.00     0.00  __gnu_cxx::__normal_iterator&lt;int*, std::vector&lt;int, std::allocator&lt;int> > >::__normal_iterator(int* const&amp;)<\/code><\/pre>\n<p>\u0418 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u043e\u043a\u043e\u043b\u043e \u043e\u0434\u043d\u043e\u0439 \u0441 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044c\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>\u0420\u0430\u0437 \u0442\u0430\u043a\u043e\u0435 \u0434\u0435\u043b\u043e, \u044f \u0440\u0435\u0448\u0438\u043b \u0443\u0431\u0440\u0430\u0442\u044c tuple \u0438\u0437 \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043e\u0434\u0430. \u042f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u044d\u0442\u043e\u0442 tuple \u0432 \u0432\u0438\u0434\u0435 int, \u0441\u0447\u0438\u0442\u0430\u044f, \u0447\u0442\u043e tuple \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, <code>tuple(i, j, k) = i*6 + j*3 + k.<\/code> \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f 6 \u0438 3 \u0432\u044b\u0445\u043e\u0434\u044f\u0442 \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 tuple \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0439\u0442\u0438. \u0414\u0435\u043b\u0430\u044e \u043f\u0440\u043e\u0444\u0438\u043b\u044c, \u043f\u043e\u043b\u0443\u0447\u0430\u044e:<\/p>\n<pre><code>  2.40      9.72     0.27 505560900     0.00     0.00  std::less&lt;int>::operator()(int const&amp;, int const&amp;) const   2.32      9.98     0.26 25994400     0.00      0.00  std::_Rb_tree&lt;int, std::pair&lt;int const, int>, std::_Select1st&lt;std::pair&lt;int const, int> >, std::less&lt;int>, std::allocator&lt;std::pair&lt;int const, int> > >::_M_lower_bound(std::_Rb_tree_node&lt;std::pair&lt;int const, int> >*, std::_Rb_tree_node_base*, int const&amp;)   1.51     10.15     0.17 503228700     0.00     0.00  std::_Rb_tree&lt;int, std::pair&lt;int const, int>, std::_Select1st&lt;std::pair&lt;int const, int> >, std::less&lt;int>, std::allocator&lt;std::pair&lt;int const, int> > >::_S_key(std::_Rb_tree_node&lt;std::pair&lt;int const, int> > const*)   1.42     10.31     0.16 503228700     0.00     0.00  std::_Rb_tree_node&lt;std::pair&lt;int const, int> >::_M_valptr() const   1.25     10.45     0.14 503228700     0.00     0.00  __gnu_cxx::__aligned_membuf&lt;std::pair&lt;int const, int> >::_M_ptr() const<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u0434\u0435\u0440\u0435\u0432\u044c\u044f. \u041f\u043e\u0433\u0443\u0433\u043b\u0438\u0432, \u044f \u0443\u0437\u043d\u0430\u043b, \u0447\u0442\u043e map \u0432 C++ &#8212; \u044d\u0442\u043e \u0434\u0435\u0440\u0435\u0432\u043e, \u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e unordered_map (\u043f\u0440\u0430\u0432\u0434\u0430 \u0441\u0434\u0435\u043b\u0430\u043b \u044f \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f). \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0435\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0431\u044b\u043b\u0430 O(n*logn), \u0430 \u043d\u0435 O(n).<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u0437\u0430\u043c\u0435\u043d\u0438\u043b map \u043d\u0430 unordered_map, \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0430\u043b\u0430 O(n). \u0422.\u043a. \u044d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 std::hash \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u044d\u0448\u0430, \u0432\u0435\u0440\u043d\u0443\u0442\u044c tuple \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e int. \u0414\u0435\u043b\u0430\u044e \u043f\u0440\u043e\u0444\u0438\u043b\u044c:<\/p>\n<pre><code>  2.17      2.47     0.07 25554600     0.00     0.00  std::__detail::_Hash_node&lt;std::pair&lt;int const, int>, false>::_M_next() const   1.55      2.52     0.05 24994400     0.00     0.00  std::_Hashtable&lt;int, std::pair&lt;int const, int>, std::allocator&lt;std::pair&lt;int const, int> >, std::__detail::_Select1st, std::equal_to&lt;int>, std::hash&lt;int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits&lt;false, false, true> >::_M_find_before_node(unsigned long long, int const&amp;, unsigned long long) const   1.55      2.57     0.05      100     0.50     7.74  helper(int, int, int, std::unordered_map&lt;int, int, std::hash&lt;int>, std::equal_to&lt;int>, std::allocator&lt;std::pair&lt;int const, int> > >&amp;)<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u044e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 std::hash, \u043d\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c. \u041d\u0443\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0417\u043d\u0430\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u0430\u043f\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440. \u0422\u0430\u043a \u043a\u0430\u043a \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u044d\u0442\u043e O(1) \u0438 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u043e \u0441\u0434\u0432\u0438\u0433\u043e\u043c, \u0442\u043e \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434.<\/p>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u043b \u043c\u0430\u043f\u0443 \u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440, \u0432\u044b\u0434\u0435\u043b\u0438\u0432 \u0435\u043c\u0443 (1e6+1)*6 \u0438\u043d\u0442\u043e\u0432. \u0414\u0435\u043b\u0430\u044e \u043f\u0440\u043e\u0444\u0438\u043b\u044c, \u043f\u043e\u043b\u0443\u0447\u0430\u044e:<\/p>\n<pre><code>100.00      0.01     0.01      100   100.00   100.00  __gnu_cxx::__enable_if&lt;std::__is_scalar&lt;int>::__value, void>::__type std::__fill_a1&lt;int*, int>(int*, int*, int const&amp;)   0.00      0.01     0.00      300     0.00     0.00  std::__new_allocator&lt;int>::~__new_allocator()   0.00      0.01     0.00      200     0.00     0.00  std::__new_allocator&lt;int>::_M_max_size() const   0.00      0.01     0.00      200     0.00     0.00  std::allocator&lt;int>::~allocator()<\/code><\/pre>\n<p>\u0412\u0443\u0430\u043b\u044f, \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0449\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c.<\/p>\n<p><strong>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/strong><\/p>\n<p>\u0427\u0442\u043e \u044f \u0445\u043e\u0442\u0435\u043b \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439. \u042f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u0430\u043c\u0438 \u0442\u0435\u043c, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0437\u043d\u0430\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0432\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0443\u0442, \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0441\u043e \u043c\u043d\u043e\u0439 \u043d\u0430 Leetcode. \u0412\u0435\u0434\u044c \u043f\u043e \u0441\u0443\u0442\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0430 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0430\u043c\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043a\u0430\u043a-\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f? \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0412\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0431\u044b. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0447\u0435\u043c \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<p>\u0418 \u0432 \u0437\u0430\u0449\u0438\u0442\u0443 \u0441\u0435\u0431\u044f \u043e\u0442 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u0445\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044f \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0432\u044b\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0441\u0432\u043e\u044e \u043e\u0431\u0438\u0434\u0443 \u0438\u043b\u0438 \u043d\u0430\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c\u0441\u044f \ud83d\ude42<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u044e\u0441\u044c \u0441\u0432\u043e\u0438\u043c \u0442\u0430\u043a\u0438\u043c \u0432\u043e\u0442 \u043e\u043f\u044b\u0442\u043e\u043c.<\/p>\n<p><em>P.S. \u042d\u0442\u043e\u0439 \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044f \u043d\u0435 \u0434\u043e\u0433\u043b\u044f\u0434\u0435\u043b (\u043f\u0435\u0440\u0435\u0434\u0430\u043b \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0430 \u043d\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435) \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043b.<\/em><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/817501\/\"> https:\/\/habr.com\/ru\/articles\/817501\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-377758","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=377758"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377758\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=377758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=377758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=377758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}