Submission #911286

# Submission time Handle Problem Language Result Execution time Memory
911286 2024-01-18T17:52:31 Z marvinthang Soccer Stadium (IOI23_soccer) C++17
100 / 100
384 ms 47896 KB
/*************************************
*    author: marvinthang             *
*    created: 18.01.2024 23:36:31    *
*************************************/

#include "soccer.h"
#include <bits/stdc++.h>

using namespace std;

#define                  fi  first
#define                  se  second
#define                left  ___left
#define               right  ___right
#define                TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define             MASK(i)  (1LL << (i))
#define           BIT(x, i)  ((x) >> (i) & 1)
#define  __builtin_popcount  __builtin_popcountll
#define              ALL(v)  (v).begin(), (v).end()
#define           REP(i, n)  for (int i = 0, _n = (n); i < _n; ++i)
#define          REPD(i, n)  for (int i = (n); i-- > 0; )
#define        FOR(i, a, b)  for (int i = (a), _b = (b); i < _b; ++i) 
#define       FORD(i, b, a)  for (int i = (b), _a = (a); --i >= _a; ) 
#define       FORE(i, a, b)  for (int i = (a), _b = (b); i <= _b; ++i) 
#define      FORDE(i, b, a)  for (int i = (b), _a = (a); i >= _a; --i) 
#define        scan_op(...)  istream & operator >> (istream &in, __VA_ARGS__ &u)
#define       print_op(...)  ostream & operator << (ostream &out, const __VA_ARGS__ &u)
#ifdef LOCAL
    #include "debug.h"
#else
    #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
    #define DB(...) 23
    #define db(...) 23
    #define debug(...) 23
#endif

template <class U, class V> scan_op(pair <U, V>)  { return in >> u.first >> u.second; }
template <class T> scan_op(vector <T>)  { for (size_t i = 0; i < u.size(); ++i) in >> u[i]; return in; }
template <class U, class V> print_op(pair <U, V>)  { return out << '(' << u.first << ", " << u.second << ')'; }
template <size_t i, class T> ostream & print_tuple_utils(ostream &out, const T &tup) { if constexpr(i == tuple_size<T>::value) return out << ")";  else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup); }
template <class ...U> print_op(tuple<U...>) { return print_tuple_utils<0, tuple<U...>>(out, u); }
template <class Con, class = decltype(begin(declval<Con>()))> typename enable_if <!is_same<Con, string>::value, ostream&>::type operator << (ostream &out, const Con &con) { out << '{'; for (__typeof(con.begin()) it = con.begin(); it != con.end(); ++it) out << (it == con.begin() ? "" : ", ") << *it; return out << '}'; }
template <class A, class B> bool minimize(A &a, B b)  { return a > b ? a = b, true : false; }
template <class A, class B> bool maximize(A &a, B b)  { return a < b ? a = b, true : false; }

// end of template

int biggest_stadium(int N, vector <vector <int>> F) {
    vector <int> dp(N), nxt_dp(N), heights(N, -1);
    int res = 0;
    vector <vector <int>> inHeight(N);
    vector <int> left(N), right(N);
    REP(r, N) {
        REP(c, N) {
            if (F[r][c]) {
                heights[c] = -1;
                dp[c] = 0;
            } else inHeight[++heights[c]].push_back(c);
        }
        stack <int> st;
        REP(i, N) {
            while (!st.empty() && heights[st.top()] >= heights[i]) st.pop();
            left[i] = st.empty() ? -1 : st.top();
            st.push(i);
        }
        while (!st.empty()) st.pop();
        REPD(i, N) {
            while (!st.empty() && heights[st.top()] >= heights[i]) st.pop();
            right[i] = st.empty() ? N : st.top();
            st.push(i);
        }
        REP(h, N) {
            for (int c: inHeight[h]) {
                int len = right[c] - left[c] - 1;
                dp[c] += len;
                if (left[c] >= 0) maximize(dp[c], dp[left[c]] + len * (h - heights[left[c]]));
                if (right[c] < N) maximize(dp[c], dp[right[c]] + len * (h - heights[right[c]]));
                maximize(res, dp[c]);
            }
            inHeight[h].clear();
        }
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 1 ms 344 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 19 ms 3416 KB ok
9 Correct 296 ms 47892 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 1 ms 348 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 1 ms 348 KB ok
13 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 1 ms 348 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 1 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 1 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Correct 1 ms 348 KB ok
16 Correct 1 ms 348 KB ok
17 Correct 0 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Correct 0 ms 348 KB ok
20 Correct 1 ms 348 KB ok
21 Correct 1 ms 348 KB ok
22 Correct 0 ms 344 KB ok
23 Correct 1 ms 344 KB ok
24 Correct 1 ms 348 KB ok
25 Correct 0 ms 348 KB ok
26 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 1 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 1 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Correct 1 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 1 ms 348 KB ok
18 Correct 1 ms 348 KB ok
19 Correct 0 ms 348 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 1 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Correct 0 ms 344 KB ok
25 Correct 1 ms 344 KB ok
26 Correct 1 ms 348 KB ok
27 Correct 0 ms 348 KB ok
28 Correct 0 ms 348 KB ok
29 Correct 1 ms 344 KB ok
30 Correct 1 ms 348 KB ok
31 Correct 1 ms 348 KB ok
32 Correct 0 ms 344 KB ok
33 Correct 0 ms 348 KB ok
34 Correct 1 ms 348 KB ok
35 Correct 0 ms 348 KB ok
36 Correct 1 ms 348 KB ok
37 Correct 1 ms 348 KB ok
38 Correct 0 ms 348 KB ok
39 Correct 1 ms 348 KB ok
40 Correct 0 ms 348 KB ok
41 Correct 0 ms 360 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 1 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 1 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Correct 1 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 1 ms 348 KB ok
18 Correct 1 ms 348 KB ok
19 Correct 0 ms 348 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 1 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Correct 0 ms 344 KB ok
25 Correct 1 ms 344 KB ok
26 Correct 1 ms 348 KB ok
27 Correct 0 ms 348 KB ok
28 Correct 0 ms 348 KB ok
29 Correct 1 ms 344 KB ok
30 Correct 1 ms 348 KB ok
31 Correct 1 ms 348 KB ok
32 Correct 0 ms 344 KB ok
33 Correct 0 ms 348 KB ok
34 Correct 1 ms 348 KB ok
35 Correct 0 ms 348 KB ok
36 Correct 1 ms 348 KB ok
37 Correct 1 ms 348 KB ok
38 Correct 0 ms 348 KB ok
39 Correct 1 ms 348 KB ok
40 Correct 0 ms 348 KB ok
41 Correct 0 ms 360 KB ok
42 Correct 24 ms 2408 KB ok
43 Correct 37 ms 2436 KB ok
44 Correct 22 ms 2716 KB ok
45 Correct 30 ms 2908 KB ok
46 Correct 24 ms 2396 KB ok
47 Correct 19 ms 3420 KB ok
48 Correct 18 ms 2396 KB ok
49 Correct 19 ms 2392 KB ok
50 Correct 19 ms 2908 KB ok
51 Correct 34 ms 2448 KB ok
52 Correct 18 ms 2456 KB ok
53 Correct 18 ms 2392 KB ok
54 Correct 18 ms 2396 KB ok
55 Correct 19 ms 2456 KB ok
56 Correct 37 ms 2644 KB ok
57 Correct 21 ms 2904 KB ok
58 Correct 21 ms 2904 KB ok
59 Correct 19 ms 2880 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 1 ms 344 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 19 ms 3416 KB ok
10 Correct 296 ms 47892 KB ok
11 Correct 1 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Correct 0 ms 348 KB ok
16 Correct 1 ms 348 KB ok
17 Correct 0 ms 348 KB ok
18 Correct 1 ms 348 KB ok
19 Correct 0 ms 348 KB ok
20 Correct 1 ms 348 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 1 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 0 ms 348 KB ok
26 Correct 0 ms 348 KB ok
27 Correct 1 ms 348 KB ok
28 Correct 1 ms 348 KB ok
29 Correct 0 ms 344 KB ok
30 Correct 1 ms 344 KB ok
31 Correct 1 ms 348 KB ok
32 Correct 0 ms 348 KB ok
33 Correct 0 ms 348 KB ok
34 Correct 1 ms 344 KB ok
35 Correct 1 ms 348 KB ok
36 Correct 1 ms 348 KB ok
37 Correct 0 ms 344 KB ok
38 Correct 0 ms 348 KB ok
39 Correct 1 ms 348 KB ok
40 Correct 0 ms 348 KB ok
41 Correct 1 ms 348 KB ok
42 Correct 1 ms 348 KB ok
43 Correct 0 ms 348 KB ok
44 Correct 1 ms 348 KB ok
45 Correct 0 ms 348 KB ok
46 Correct 0 ms 360 KB ok
47 Correct 24 ms 2408 KB ok
48 Correct 37 ms 2436 KB ok
49 Correct 22 ms 2716 KB ok
50 Correct 30 ms 2908 KB ok
51 Correct 24 ms 2396 KB ok
52 Correct 19 ms 3420 KB ok
53 Correct 18 ms 2396 KB ok
54 Correct 19 ms 2392 KB ok
55 Correct 19 ms 2908 KB ok
56 Correct 34 ms 2448 KB ok
57 Correct 18 ms 2456 KB ok
58 Correct 18 ms 2392 KB ok
59 Correct 18 ms 2396 KB ok
60 Correct 19 ms 2456 KB ok
61 Correct 37 ms 2644 KB ok
62 Correct 21 ms 2904 KB ok
63 Correct 21 ms 2904 KB ok
64 Correct 19 ms 2880 KB ok
65 Correct 384 ms 32020 KB ok
66 Correct 337 ms 31768 KB ok
67 Correct 313 ms 31960 KB ok
68 Correct 357 ms 40924 KB ok
69 Correct 374 ms 32792 KB ok
70 Correct 376 ms 32340 KB ok
71 Correct 337 ms 44884 KB ok
72 Correct 308 ms 47896 KB ok
73 Correct 296 ms 32596 KB ok
74 Correct 292 ms 32340 KB ok
75 Correct 290 ms 32296 KB ok
76 Correct 315 ms 39956 KB ok
77 Correct 294 ms 39980 KB ok
78 Correct 334 ms 34584 KB ok
79 Correct 276 ms 31784 KB ok
80 Correct 292 ms 31764 KB ok
81 Correct 286 ms 31752 KB ok
82 Correct 291 ms 31968 KB ok
83 Correct 322 ms 31960 KB ok
84 Correct 272 ms 31824 KB ok
85 Correct 275 ms 31768 KB ok
86 Correct 273 ms 31960 KB ok
87 Correct 292 ms 32788 KB ok
88 Correct 279 ms 38996 KB ok
89 Correct 301 ms 47784 KB ok
90 Correct 300 ms 47892 KB ok
91 Correct 308 ms 40528 KB ok
92 Correct 284 ms 31964 KB ok
93 Correct 288 ms 31780 KB ok
94 Correct 315 ms 31824 KB ok
95 Correct 268 ms 31824 KB ok
96 Correct 298 ms 31828 KB ok
97 Correct 318 ms 31772 KB ok
98 Correct 274 ms 31768 KB ok
99 Correct 300 ms 32848 KB ok
100 Correct 302 ms 42324 KB ok
101 Correct 318 ms 43268 KB ok
102 Correct 308 ms 42324 KB ok
103 Correct 304 ms 41552 KB ok
104 Correct 311 ms 41044 KB ok
105 Correct 308 ms 40532 KB ok
106 Correct 315 ms 40060 KB ok
107 Correct 318 ms 39716 KB ok
108 Correct 305 ms 32552 KB ok
109 Correct 328 ms 33304 KB ok