Submission #1028027

# Submission time Handle Problem Language Result Execution time Memory
1028027 2024-07-19T12:34:02 Z Mr_Husanboy Soccer Stadium (IOI23_soccer) C++17
29.5 / 100
613 ms 102916 KB
#include "soccer.h"
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
 
template<typename T>
int len(T &a){return a.size();}
 
 
 
int biggest_stadium(int n, vector<vector<int>> f)
{
 
    vector uplef(n, vector(n, 0)), uprig(n, vector(n, 0));
    vector dolef(n, vector(n, 0)), dorig(n, vector(n, 0));
    vector<int> con(n, 0);
    int emp = 0;
    for(int j = 0; j < n; j ++){
        for(int i = 0; i < n; i ++){
            if(f[i][j]){
                con[i] = 0;
            }else{
                emp ++;
                con[i] ++;
            }
        }
        vector<int> near(n), st;
        for(int i = 0; i < n; i ++){
            while(!st.empty() && con[st.back()] >= con[i]) st.pop_back();
            if(st.empty()) near[i] = -1;
            else near[i] = st.back();
            st.push_back(i);
        }
        for(int i = 0; i < n; i ++){
            uplef[i][j] = con[i] * (i - near[i]);
            if(near[i] != -1){
                uplef[i][j] += uplef[near[i]][j];
            }
        }
    }   
    con.assign(n, 0);
    for(int j = n - 1; j >= 0; j --){
        for(int i = 0; i < n; i ++){
            if(f[i][j]){
                con[i] = 0;
            }else con[i] ++;
        }
        vector<int> near(n), st;
        for(int i = 0; i < n; i ++){
            while(!st.empty() && con[st.back()] >= con[i]) st.pop_back();
            if(st.empty()) near[i] = -1;
            else near[i] = st.back();
            st.push_back(i);
        }
        for(int i = 0; i < n; i ++){
            uprig[i][j] = con[i] * (i - near[i]);
            if(near[i] != -1){
                uprig[i][j] += uprig[near[i]][j];
            }
        }
    }
    con.assign(n, 0);
    for(int j = n - 1; j >= 0; j --){
        for(int i = n - 1; i >= 0; i --){
            if(f[i][j]){
                con[i] = 0;
            }else con[i] ++;
        }
        vector<int> near(n), st;
        for(int i = n - 1; i >= 0; i --){
            while(!st.empty() && con[st.back()] >= con[i]) st.pop_back();
            if(st.empty()) near[i] = n;
            else near[i] = st.back();
            st.push_back(i);
        }
        for(int i = n - 1; i >= 0; i --){
            dorig[i][j] = con[i] * (near[i] - i);
            if(near[i] != n){
                dorig[i][j] += dorig[near[i]][j];
            }
        }
    }
    con.assign(n, 0);
    for(int j = 0; j < n; j ++){
        for(int i = 0; i < n; i ++){
            if(f[i][j]){
                con[i] = 0;
            }else con[i] ++;
        }
        vector<int> near(n), st;
        for(int i = n - 1; i >= 0; i --){
            while(!st.empty() && con[st.back()] >= con[i]) st.pop_back();
            if(st.empty()) near[i] = n;
            else near[i] = st.back();
            st.push_back(i);
        }
        for(int i = n - 1; i >= 0; i --){
            dolef[i][j] = con[i] * (near[i] - i);
            if(near[i] != n){
                dolef[i][j] += dolef[near[i]][j];
            }
        }
    }
    int ans = 0;
    
    for(int j = 0; j < n; j ++){
        for(int i = 0; i < n; i ++){
            int cnt = uplef[i][j];
            if(j + 1 < n){
                cnt += uprig[i][j + 1];
            }
            if(i + 1 < n){
                cnt += dolef[i + 1][j];
            }
            if(i + 1 < n && j + 1 < n){
                cnt += dorig[i + 1][j + 1];
            }
            ans = max(ans, cnt);
        }
    }
 
    if(ans != emp){
        return ans;
    }
    vector<pair<int,int>> a(n);
    int mx = 0;
    for(int i = 0; i < n; i ++){
        a[i].ff = n, a[i].ss = 0;
        for(int j = 0; j < n; j ++){
            if(f[i][j] == 0){
                a[i].ff = min(a[i].ff, j);
                a[i].ss = max(a[i].ss, j);
            }
        }
        mx = max(mx, a[i].ss - a[i].ff + 1);
    }
    int mid = 0;
    for(int i = 0; i < n; i ++){
        if(mx == a[i].ss - a[i].ff + 1){
            mid = i; break;
        }
    }
    int l = mid, r = mid;
 
    while(r < n && l >= 0){
        while(l >= 0 && a[l].ff <= a[r].ff && a[r].ss <= a[l].ss){
            l --;
        }
        if(l >= 0 && not(a[r].ff <= a[l].ff && a[l].ss <= a[r].ss)){
            return 0;
        }
        r ++;
    }
 
    return emp;
}
# Verdict Execution time Memory Grader output
1 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 1 ms 432 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 0 ms 344 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 2 ms 604 KB ok
8 Correct 21 ms 6844 KB ok
9 Correct 466 ms 102528 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 0 ms 348 KB ok
5 Partially correct 0 ms 348 KB partial
6 Correct 0 ms 348 KB ok
7 Partially correct 0 ms 436 KB partial
8 Correct 0 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 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 Partially correct 0 ms 348 KB partial
7 Correct 0 ms 348 KB ok
8 Partially correct 0 ms 436 KB partial
9 Correct 0 ms 348 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
14 Correct 0 ms 348 KB ok
15 Correct 1 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Partially correct 0 ms 348 KB partial
18 Partially correct 0 ms 348 KB partial
19 Correct 0 ms 348 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 1 ms 348 KB ok
22 Partially correct 1 ms 348 KB partial
23 Partially correct 0 ms 436 KB partial
24 Partially correct 1 ms 348 KB partial
25 Partially correct 0 ms 436 KB partial
26 Partially correct 1 ms 348 KB partial
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 432 KB ok
5 Correct 1 ms 344 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Partially correct 0 ms 348 KB partial
9 Correct 0 ms 348 KB ok
10 Partially correct 0 ms 436 KB partial
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 0 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 1 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Partially correct 0 ms 348 KB partial
20 Partially correct 0 ms 348 KB partial
21 Correct 0 ms 348 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Partially correct 1 ms 348 KB partial
25 Partially correct 0 ms 436 KB partial
26 Partially correct 1 ms 348 KB partial
27 Partially correct 0 ms 436 KB partial
28 Partially correct 1 ms 348 KB partial
29 Partially correct 1 ms 348 KB partial
30 Partially correct 1 ms 348 KB partial
31 Partially correct 1 ms 432 KB partial
32 Correct 1 ms 348 KB ok
33 Correct 0 ms 348 KB ok
34 Correct 0 ms 348 KB ok
35 Correct 0 ms 348 KB ok
36 Partially correct 0 ms 348 KB partial
37 Partially correct 1 ms 348 KB partial
38 Partially correct 0 ms 348 KB partial
39 Partially correct 1 ms 348 KB partial
40 Correct 1 ms 348 KB ok
41 Partially correct 0 ms 432 KB partial
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 432 KB ok
5 Correct 1 ms 344 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Partially correct 0 ms 348 KB partial
9 Correct 0 ms 348 KB ok
10 Partially correct 0 ms 436 KB partial
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 0 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 1 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Partially correct 0 ms 348 KB partial
20 Partially correct 0 ms 348 KB partial
21 Correct 0 ms 348 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Partially correct 1 ms 348 KB partial
25 Partially correct 0 ms 436 KB partial
26 Partially correct 1 ms 348 KB partial
27 Partially correct 0 ms 436 KB partial
28 Partially correct 1 ms 348 KB partial
29 Partially correct 1 ms 348 KB partial
30 Partially correct 1 ms 348 KB partial
31 Partially correct 1 ms 432 KB partial
32 Correct 1 ms 348 KB ok
33 Correct 0 ms 348 KB ok
34 Correct 0 ms 348 KB ok
35 Correct 0 ms 348 KB ok
36 Partially correct 0 ms 348 KB partial
37 Partially correct 1 ms 348 KB partial
38 Partially correct 0 ms 348 KB partial
39 Partially correct 1 ms 348 KB partial
40 Correct 1 ms 348 KB ok
41 Partially correct 0 ms 432 KB partial
42 Partially correct 32 ms 6740 KB partial
43 Partially correct 32 ms 6748 KB partial
44 Partially correct 24 ms 6748 KB partial
45 Partially correct 22 ms 6748 KB partial
46 Partially correct 26 ms 6748 KB partial
47 Partially correct 20 ms 6748 KB partial
48 Correct 23 ms 6748 KB ok
49 Partially correct 20 ms 6744 KB partial
50 Correct 21 ms 6784 KB ok
51 Partially correct 22 ms 6748 KB partial
52 Partially correct 19 ms 6748 KB partial
53 Partially correct 32 ms 6748 KB partial
54 Partially correct 23 ms 6748 KB partial
55 Partially correct 20 ms 6748 KB partial
56 Correct 21 ms 6748 KB ok
57 Partially correct 21 ms 6792 KB partial
58 Partially correct 20 ms 6748 KB partial
59 Partially correct 20 ms 7000 KB partial
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 432 KB ok
5 Correct 1 ms 344 KB ok
6 Correct 0 ms 344 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 2 ms 604 KB ok
9 Correct 21 ms 6844 KB ok
10 Correct 466 ms 102528 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Partially correct 0 ms 348 KB partial
14 Correct 0 ms 348 KB ok
15 Partially correct 0 ms 436 KB partial
16 Correct 0 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 0 ms 348 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 1 ms 348 KB ok
23 Correct 0 ms 348 KB ok
24 Partially correct 0 ms 348 KB partial
25 Partially correct 0 ms 348 KB partial
26 Correct 0 ms 348 KB ok
27 Correct 0 ms 348 KB ok
28 Correct 1 ms 348 KB ok
29 Partially correct 1 ms 348 KB partial
30 Partially correct 0 ms 436 KB partial
31 Partially correct 1 ms 348 KB partial
32 Partially correct 0 ms 436 KB partial
33 Partially correct 1 ms 348 KB partial
34 Partially correct 1 ms 348 KB partial
35 Partially correct 1 ms 348 KB partial
36 Partially correct 1 ms 432 KB partial
37 Correct 1 ms 348 KB ok
38 Correct 0 ms 348 KB ok
39 Correct 0 ms 348 KB ok
40 Correct 0 ms 348 KB ok
41 Partially correct 0 ms 348 KB partial
42 Partially correct 1 ms 348 KB partial
43 Partially correct 0 ms 348 KB partial
44 Partially correct 1 ms 348 KB partial
45 Correct 1 ms 348 KB ok
46 Partially correct 0 ms 432 KB partial
47 Partially correct 32 ms 6740 KB partial
48 Partially correct 32 ms 6748 KB partial
49 Partially correct 24 ms 6748 KB partial
50 Partially correct 22 ms 6748 KB partial
51 Partially correct 26 ms 6748 KB partial
52 Partially correct 20 ms 6748 KB partial
53 Correct 23 ms 6748 KB ok
54 Partially correct 20 ms 6744 KB partial
55 Correct 21 ms 6784 KB ok
56 Partially correct 22 ms 6748 KB partial
57 Partially correct 19 ms 6748 KB partial
58 Partially correct 32 ms 6748 KB partial
59 Partially correct 23 ms 6748 KB partial
60 Partially correct 20 ms 6748 KB partial
61 Correct 21 ms 6748 KB ok
62 Partially correct 21 ms 6792 KB partial
63 Partially correct 20 ms 6748 KB partial
64 Partially correct 20 ms 7000 KB partial
65 Partially correct 613 ms 102544 KB partial
66 Correct 557 ms 102664 KB ok
67 Partially correct 506 ms 102484 KB partial
68 Partially correct 473 ms 102484 KB partial
69 Partially correct 522 ms 102484 KB partial
70 Partially correct 549 ms 102540 KB partial
71 Partially correct 521 ms 102484 KB partial
72 Partially correct 484 ms 102484 KB partial
73 Correct 517 ms 102540 KB ok
74 Correct 449 ms 102644 KB ok
75 Correct 489 ms 102552 KB ok
76 Correct 461 ms 102484 KB ok
77 Correct 444 ms 102484 KB ok
78 Partially correct 455 ms 102484 KB partial
79 Partially correct 454 ms 102484 KB partial
80 Partially correct 440 ms 102416 KB partial
81 Partially correct 450 ms 102552 KB partial
82 Partially correct 478 ms 102808 KB partial
83 Partially correct 506 ms 102424 KB partial
84 Partially correct 465 ms 102536 KB partial
85 Partially correct 438 ms 102484 KB partial
86 Partially correct 461 ms 102668 KB partial
87 Partially correct 463 ms 102668 KB partial
88 Correct 495 ms 102408 KB ok
89 Partially correct 508 ms 102680 KB partial
90 Partially correct 507 ms 102660 KB partial
91 Partially correct 490 ms 102484 KB partial
92 Correct 485 ms 102484 KB ok
93 Correct 502 ms 102416 KB ok
94 Correct 520 ms 102484 KB ok
95 Partially correct 472 ms 102664 KB partial
96 Partially correct 504 ms 102540 KB partial
97 Partially correct 498 ms 102796 KB partial
98 Correct 468 ms 102664 KB ok
99 Correct 499 ms 102668 KB ok
100 Partially correct 495 ms 102740 KB partial
101 Partially correct 468 ms 102488 KB partial
102 Partially correct 476 ms 102540 KB partial
103 Partially correct 482 ms 102424 KB partial
104 Partially correct 502 ms 102556 KB partial
105 Partially correct 503 ms 102484 KB partial
106 Partially correct 482 ms 102916 KB partial
107 Partially correct 475 ms 102548 KB partial
108 Correct 471 ms 102484 KB ok
109 Correct 483 ms 102420 KB ok