Submission #911285

# Submission time Handle Problem Language Result Execution time Memory
911285 2024-01-18T17:52:00 Z marvinthang Soccer Stadium (IOI23_soccer) C++17
100 / 100
393 ms 47952 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 1 ms 600 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 344 KB ok
7 Correct 1 ms 344 KB ok
8 Correct 18 ms 3224 KB ok
9 Correct 306 ms 47896 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 1 ms 344 KB ok
4 Correct 1 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 1 ms 588 KB ok
7 Correct 1 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 344 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 344 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB ok
2 Correct 1 ms 344 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 1 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 1 ms 588 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 1 ms 344 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 344 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 0 ms 348 KB ok
23 Correct 0 ms 348 KB ok
24 Correct 0 ms 388 KB ok
25 Correct 1 ms 348 KB ok
26 Correct 1 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB ok
2 Correct 1 ms 344 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 1 ms 344 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 1 ms 588 KB ok
10 Correct 1 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
14 Correct 1 ms 344 KB ok
15 Correct 0 ms 348 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 1 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Correct 1 ms 348 KB ok
20 Correct 1 ms 348 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 0 ms 348 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 0 ms 348 KB ok
26 Correct 0 ms 388 KB ok
27 Correct 1 ms 348 KB ok
28 Correct 1 ms 348 KB ok
29 Correct 1 ms 344 KB ok
30 Correct 1 ms 344 KB ok
31 Correct 1 ms 344 KB ok
32 Correct 0 ms 348 KB ok
33 Correct 1 ms 344 KB ok
34 Correct 1 ms 348 KB ok
35 Correct 0 ms 348 KB ok
36 Correct 1 ms 344 KB ok
37 Correct 0 ms 348 KB ok
38 Correct 1 ms 344 KB ok
39 Correct 1 ms 348 KB ok
40 Correct 0 ms 348 KB ok
41 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB ok
2 Correct 1 ms 344 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 1 ms 344 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 1 ms 588 KB ok
10 Correct 1 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
14 Correct 1 ms 344 KB ok
15 Correct 0 ms 348 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 1 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Correct 1 ms 348 KB ok
20 Correct 1 ms 348 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 0 ms 348 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 0 ms 348 KB ok
26 Correct 0 ms 388 KB ok
27 Correct 1 ms 348 KB ok
28 Correct 1 ms 348 KB ok
29 Correct 1 ms 344 KB ok
30 Correct 1 ms 344 KB ok
31 Correct 1 ms 344 KB ok
32 Correct 0 ms 348 KB ok
33 Correct 1 ms 344 KB ok
34 Correct 1 ms 348 KB ok
35 Correct 0 ms 348 KB ok
36 Correct 1 ms 344 KB ok
37 Correct 0 ms 348 KB ok
38 Correct 1 ms 344 KB ok
39 Correct 1 ms 348 KB ok
40 Correct 0 ms 348 KB ok
41 Correct 0 ms 348 KB ok
42 Correct 24 ms 2652 KB ok
43 Correct 24 ms 2396 KB ok
44 Correct 22 ms 2648 KB ok
45 Correct 21 ms 2908 KB ok
46 Correct 24 ms 2396 KB ok
47 Correct 25 ms 3420 KB ok
48 Correct 18 ms 2396 KB ok
49 Correct 18 ms 2392 KB ok
50 Correct 19 ms 2904 KB ok
51 Correct 20 ms 2464 KB ok
52 Correct 17 ms 2396 KB ok
53 Correct 17 ms 2392 KB ok
54 Correct 17 ms 2396 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 2908 KB ok
59 Correct 18 ms 2908 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB ok
2 Correct 1 ms 344 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 1 ms 344 KB ok
8 Correct 1 ms 344 KB ok
9 Correct 18 ms 3224 KB ok
10 Correct 306 ms 47896 KB ok
11 Correct 1 ms 344 KB ok
12 Correct 1 ms 348 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 1 ms 588 KB ok
15 Correct 1 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 0 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Correct 1 ms 344 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 1 ms 348 KB ok
23 Correct 0 ms 348 KB ok
24 Correct 1 ms 348 KB ok
25 Correct 1 ms 348 KB ok
26 Correct 0 ms 348 KB ok
27 Correct 0 ms 348 KB ok
28 Correct 0 ms 348 KB ok
29 Correct 0 ms 348 KB ok
30 Correct 0 ms 348 KB ok
31 Correct 0 ms 388 KB ok
32 Correct 1 ms 348 KB ok
33 Correct 1 ms 348 KB ok
34 Correct 1 ms 344 KB ok
35 Correct 1 ms 344 KB ok
36 Correct 1 ms 344 KB ok
37 Correct 0 ms 348 KB ok
38 Correct 1 ms 344 KB ok
39 Correct 1 ms 348 KB ok
40 Correct 0 ms 348 KB ok
41 Correct 1 ms 344 KB ok
42 Correct 0 ms 348 KB ok
43 Correct 1 ms 344 KB ok
44 Correct 1 ms 348 KB ok
45 Correct 0 ms 348 KB ok
46 Correct 0 ms 348 KB ok
47 Correct 24 ms 2652 KB ok
48 Correct 24 ms 2396 KB ok
49 Correct 22 ms 2648 KB ok
50 Correct 21 ms 2908 KB ok
51 Correct 24 ms 2396 KB ok
52 Correct 25 ms 3420 KB ok
53 Correct 18 ms 2396 KB ok
54 Correct 18 ms 2392 KB ok
55 Correct 19 ms 2904 KB ok
56 Correct 20 ms 2464 KB ok
57 Correct 17 ms 2396 KB ok
58 Correct 17 ms 2392 KB ok
59 Correct 17 ms 2396 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 2908 KB ok
64 Correct 18 ms 2908 KB ok
65 Correct 393 ms 32036 KB ok
66 Correct 327 ms 32020 KB ok
67 Correct 281 ms 31960 KB ok
68 Correct 354 ms 40980 KB ok
69 Correct 389 ms 32784 KB ok
70 Correct 384 ms 32536 KB ok
71 Correct 338 ms 44896 KB ok
72 Correct 311 ms 47952 KB ok
73 Correct 289 ms 32084 KB ok
74 Correct 292 ms 32336 KB ok
75 Correct 294 ms 32292 KB ok
76 Correct 294 ms 39960 KB ok
77 Correct 306 ms 40012 KB ok
78 Correct 300 ms 34648 KB ok
79 Correct 277 ms 32020 KB ok
80 Correct 276 ms 31824 KB ok
81 Correct 295 ms 31972 KB ok
82 Correct 297 ms 32080 KB ok
83 Correct 307 ms 31964 KB ok
84 Correct 278 ms 32020 KB ok
85 Correct 266 ms 31960 KB ok
86 Correct 271 ms 32036 KB ok
87 Correct 275 ms 32792 KB ok
88 Correct 285 ms 39260 KB ok
89 Correct 300 ms 47896 KB ok
90 Correct 309 ms 47952 KB ok
91 Correct 299 ms 40212 KB ok
92 Correct 290 ms 31916 KB ok
93 Correct 312 ms 31772 KB ok
94 Correct 348 ms 31824 KB ok
95 Correct 293 ms 31764 KB ok
96 Correct 283 ms 31828 KB ok
97 Correct 267 ms 31784 KB ok
98 Correct 278 ms 31828 KB ok
99 Correct 308 ms 32808 KB ok
100 Correct 309 ms 42500 KB ok
101 Correct 316 ms 43288 KB ok
102 Correct 320 ms 42668 KB ok
103 Correct 329 ms 41412 KB ok
104 Correct 321 ms 40928 KB ok
105 Correct 340 ms 40528 KB ok
106 Correct 319 ms 39976 KB ok
107 Correct 298 ms 39724 KB ok
108 Correct 310 ms 32540 KB ok
109 Correct 323 ms 33604 KB ok