Submission #911287

# Submission time Handle Problem Language Result Execution time Memory
911287 2024-01-18T17:53:08 Z marvinthang Soccer Stadium (IOI23_soccer) C++17
100 / 100
405 ms 47968 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) {
    int res = 0;
    vector <int> dp(N), heights(N, -1), left(N), right(N);
    vector <vector <int>> inHeight(N);
    stack <int> st;
    REP(r, N) {
        REP(c, N) {
            if (F[r][c]) {
                heights[c] = -1;
                dp[c] = 0;
            } else inHeight[++heights[c]].push_back(c);
        }
        while (!st.empty()) st.pop();
        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 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 1 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 32 ms 3220 KB ok
9 Correct 314 ms 47904 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 1 ms 344 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 0 ms 344 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 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 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 348 KB ok
5 Correct 1 ms 344 KB ok
6 Correct 1 ms 344 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 0 ms 344 KB ok
11 Correct 0 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 1 ms 344 KB ok
16 Correct 1 ms 344 KB ok
17 Correct 1 ms 344 KB ok
18 Correct 1 ms 348 KB ok
19 Correct 1 ms 348 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 1 ms 348 KB ok
22 Correct 1 ms 348 KB ok
23 Correct 1 ms 344 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 1 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 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 348 KB ok
5 Correct 1 ms 348 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 1 ms 344 KB ok
8 Correct 1 ms 344 KB ok
9 Correct 1 ms 348 KB ok
10 Correct 1 ms 348 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 344 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 0 ms 348 KB ok
17 Correct 1 ms 344 KB ok
18 Correct 1 ms 344 KB ok
19 Correct 1 ms 344 KB ok
20 Correct 1 ms 348 KB ok
21 Correct 1 ms 348 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Correct 1 ms 348 KB ok
25 Correct 1 ms 344 KB ok
26 Correct 0 ms 348 KB ok
27 Correct 1 ms 348 KB ok
28 Correct 0 ms 348 KB ok
29 Correct 1 ms 348 KB ok
30 Correct 1 ms 348 KB ok
31 Correct 1 ms 348 KB ok
32 Correct 1 ms 348 KB ok
33 Correct 1 ms 348 KB ok
34 Correct 1 ms 600 KB ok
35 Correct 1 ms 348 KB ok
36 Correct 0 ms 348 KB ok
37 Correct 0 ms 348 KB ok
38 Correct 1 ms 348 KB ok
39 Correct 1 ms 348 KB ok
40 Correct 1 ms 344 KB ok
41 Correct 1 ms 344 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 348 KB ok
5 Correct 1 ms 348 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 1 ms 344 KB ok
8 Correct 1 ms 344 KB ok
9 Correct 1 ms 348 KB ok
10 Correct 1 ms 348 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 344 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 0 ms 348 KB ok
17 Correct 1 ms 344 KB ok
18 Correct 1 ms 344 KB ok
19 Correct 1 ms 344 KB ok
20 Correct 1 ms 348 KB ok
21 Correct 1 ms 348 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Correct 1 ms 348 KB ok
25 Correct 1 ms 344 KB ok
26 Correct 0 ms 348 KB ok
27 Correct 1 ms 348 KB ok
28 Correct 0 ms 348 KB ok
29 Correct 1 ms 348 KB ok
30 Correct 1 ms 348 KB ok
31 Correct 1 ms 348 KB ok
32 Correct 1 ms 348 KB ok
33 Correct 1 ms 348 KB ok
34 Correct 1 ms 600 KB ok
35 Correct 1 ms 348 KB ok
36 Correct 0 ms 348 KB ok
37 Correct 0 ms 348 KB ok
38 Correct 1 ms 348 KB ok
39 Correct 1 ms 348 KB ok
40 Correct 1 ms 344 KB ok
41 Correct 1 ms 344 KB ok
42 Correct 25 ms 2392 KB ok
43 Correct 25 ms 2392 KB ok
44 Correct 29 ms 2644 KB ok
45 Correct 25 ms 2908 KB ok
46 Correct 23 ms 2392 KB ok
47 Correct 19 ms 3416 KB ok
48 Correct 19 ms 2392 KB ok
49 Correct 18 ms 2392 KB ok
50 Correct 20 ms 2904 KB ok
51 Correct 22 ms 2804 KB ok
52 Correct 18 ms 2396 KB ok
53 Correct 21 ms 2396 KB ok
54 Correct 18 ms 2392 KB ok
55 Correct 18 ms 2392 KB ok
56 Correct 18 ms 2648 KB ok
57 Correct 19 ms 2904 KB ok
58 Correct 20 ms 2904 KB ok
59 Correct 19 ms 2976 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 348 KB ok
5 Correct 1 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 32 ms 3220 KB ok
10 Correct 314 ms 47904 KB ok
11 Correct 1 ms 348 KB ok
12 Correct 1 ms 344 KB ok
13 Correct 1 ms 344 KB ok
14 Correct 1 ms 348 KB ok
15 Correct 1 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 0 ms 344 KB ok
18 Correct 0 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 344 KB ok
23 Correct 1 ms 344 KB ok
24 Correct 1 ms 344 KB ok
25 Correct 1 ms 348 KB ok
26 Correct 1 ms 348 KB ok
27 Correct 0 ms 348 KB ok
28 Correct 1 ms 348 KB ok
29 Correct 1 ms 348 KB ok
30 Correct 1 ms 344 KB ok
31 Correct 0 ms 348 KB ok
32 Correct 1 ms 348 KB ok
33 Correct 0 ms 348 KB ok
34 Correct 1 ms 348 KB ok
35 Correct 1 ms 348 KB ok
36 Correct 1 ms 348 KB ok
37 Correct 1 ms 348 KB ok
38 Correct 1 ms 348 KB ok
39 Correct 1 ms 600 KB ok
40 Correct 1 ms 348 KB ok
41 Correct 0 ms 348 KB ok
42 Correct 0 ms 348 KB ok
43 Correct 1 ms 348 KB ok
44 Correct 1 ms 348 KB ok
45 Correct 1 ms 344 KB ok
46 Correct 1 ms 344 KB ok
47 Correct 25 ms 2392 KB ok
48 Correct 25 ms 2392 KB ok
49 Correct 29 ms 2644 KB ok
50 Correct 25 ms 2908 KB ok
51 Correct 23 ms 2392 KB ok
52 Correct 19 ms 3416 KB ok
53 Correct 19 ms 2392 KB ok
54 Correct 18 ms 2392 KB ok
55 Correct 20 ms 2904 KB ok
56 Correct 22 ms 2804 KB ok
57 Correct 18 ms 2396 KB ok
58 Correct 21 ms 2396 KB ok
59 Correct 18 ms 2392 KB ok
60 Correct 18 ms 2392 KB ok
61 Correct 18 ms 2648 KB ok
62 Correct 19 ms 2904 KB ok
63 Correct 20 ms 2904 KB ok
64 Correct 19 ms 2976 KB ok
65 Correct 372 ms 32048 KB ok
66 Correct 323 ms 31828 KB ok
67 Correct 290 ms 31768 KB ok
68 Correct 344 ms 40992 KB ok
69 Correct 362 ms 33108 KB ok
70 Correct 377 ms 32296 KB ok
71 Correct 332 ms 44880 KB ok
72 Correct 305 ms 47968 KB ok
73 Correct 323 ms 32544 KB ok
74 Correct 298 ms 32268 KB ok
75 Correct 292 ms 32372 KB ok
76 Correct 293 ms 39956 KB ok
77 Correct 283 ms 39980 KB ok
78 Correct 302 ms 34588 KB ok
79 Correct 286 ms 31780 KB ok
80 Correct 282 ms 31896 KB ok
81 Correct 281 ms 31764 KB ok
82 Correct 295 ms 31832 KB ok
83 Correct 311 ms 31824 KB ok
84 Correct 277 ms 32016 KB ok
85 Correct 291 ms 31824 KB ok
86 Correct 273 ms 31828 KB ok
87 Correct 283 ms 33108 KB ok
88 Correct 281 ms 38936 KB ok
89 Correct 293 ms 47892 KB ok
90 Correct 294 ms 47952 KB ok
91 Correct 289 ms 40016 KB ok
92 Correct 289 ms 31768 KB ok
93 Correct 297 ms 32080 KB ok
94 Correct 281 ms 31824 KB ok
95 Correct 282 ms 31760 KB ok
96 Correct 279 ms 31960 KB ok
97 Correct 292 ms 31956 KB ok
98 Correct 283 ms 31768 KB ok
99 Correct 405 ms 32788 KB ok
100 Correct 324 ms 42384 KB ok
101 Correct 312 ms 43288 KB ok
102 Correct 307 ms 42544 KB ok
103 Correct 332 ms 41444 KB ok
104 Correct 314 ms 41212 KB ok
105 Correct 319 ms 40472 KB ok
106 Correct 324 ms 39956 KB ok
107 Correct 322 ms 39700 KB ok
108 Correct 337 ms 32436 KB ok
109 Correct 318 ms 33300 KB ok