답안 #885890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
885890 2023-12-11T01:54:32 Z jay_jayjay 축구 경기장 (IOI23_soccer) C++17
64 / 100
4500 ms 118100 KB
// {{{1
extern "C" int __lsan_is_turned_off() { return 1; }
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <array>
#include <vector>
#include <string>
#include <deque>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define ll long long
#define inf 0x3f3f3f3f
#define infl 0x3f3f3f3f3f3f3f3fll

#include <assert.h>
#ifdef DEBUG
#define dprintf(args...) fprintf(stderr,args)
#endif
#ifndef DEBUG
#define dprintf(args...) 69
#endif
#define all(x) (x).begin(), (x).end()
// 1}}}

#define N 2000
#define LG 20
int n;
int F[N][N];
int C[N][N];
int D[N][N];

int dp[N][N],aux[N][N];
int st_l[LG][N];
int st_r[LG][N];
// in col, row

void build(int st[LG][N], int m) {
        for(int lg = 1; lg < LG; lg++)
                for(int i=0;i+(1<<lg)<=N;i++)
                        // st[lg][i] repr [i...i+(1<<lg))
                        if(m)st[lg][i] = max(st[lg-1][i],st[lg-1][i+(1<<(lg-1))]);
                        else st[lg][i] = min(st[lg-1][i],st[lg-1][i+(1<<(lg-1))]);
}

int query(int st[LG][N],int m, int l, int r) {
        r++;
        int lg = __lg(r-l);
        //printf("l=%d r=%d lg=%d 1<<lg=%d\n",l,r,lg,1<<lg);
        if(m) return max(st[lg][l],st[lg][r-(1<<lg)]);
        else  return min(st[lg][l],st[lg][r-(1<<lg)]);
}

int solve(int c) {
        // solves if column of highest is c
        for(int y=0;y<n;y++) {
                st_l[0][y] = lower_bound(C[y],C[y]+n,C[y][c])-C[y];
                if(C[y][st_l[0][y]]==0)st_l[0][y]--;
                st_r[0][y] = upper_bound(C[y],C[y]+n,C[y][c])-C[y];
                //printf("%d, %d ( : %d)\n",st_l[0][y],st_r[0][y],C[y][c]);
        }
        build(st_l,1);
        build(st_r,0);

#define extent(l, r) (query(st_r,0,l,r) - query(st_l,1,l,r) - 1)
#define ok(l,r) (query(st_r,0,l,r)>c && query(st_l,1,l,r)<c)
#define val(l,r) (ok(l,r)?extent(l,r) : 0)
        for(int i=0;i<n;i++) {
                for(int j=n-1;j>=i;j--) {
                        dp[i][j]=val(i,j);
                }
        }
        for(int i=0;i<n;i++) {
                for(int j=n-1;j>i;j--) {
                        // transition to i+1,j
                        // and i,j-1
                        // i+1, j
                        aux[i+1][j] = val(i+1,j);
                        dp[i+1][j] = max(dp[i+1][j], (j-i) * (aux[i+1][j]-aux[i][j]) + dp[i][j]);

                        aux[i][j-1] = val(i,j-1);
                        dp[i][j-1] = max(dp[i][j-1], (j-i) * (aux[i][j-1]-aux[i][j]) + dp[i][j]);
                }
        }
        //printf("\nc=%d\n",c);
        int mx=0;
        for(int i=0;i<n;i++)
                for(int j=n-1;j>=i;j--) {
                        mx = max(mx,dp[i][j]);
                        //printf("[%d, %d] = %d\n",i,j,dp[i][j]);
                }
        //printf("c=%d: mx=%d\n",c,mx);
        return mx;
}

int biggest_stadium(int _n, vector<vector<int>> _f) {
        n=_n;
        for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                        F[i][j]=_f[i][j];
        for(int i=0;i<n;i++) {
                for(int j=0;j<n;j++)
                        C[i][j]=F[i][j];
                for(int j=1;j<n;j++)
                        C[i][j]+=C[i][j-1];
        }
        for(int i=0;i<n;i++) {
                for(int j=0;j<n;j++)
                        D[j][i]=F[j][i];
                for(int j=1;j<n;j++)
                        D[j][i]+=D[j-1][i];
        }
        //for(int i=0;i<n;i++) {
                //for(int j=0;j<n;j++)
                        //printf("%d ",F[i][j]);
                //printf("\n");
        //}
        //printf("\n");
        //for(int i=0;i<n;i++) {
                //for(int j=0;j<n;j++)
                        //printf("%d ",C[i][j]);
                //printf("\n");
        //}

        int best=0;
        for(int i=0;i<n;i++)best=max(best,solve(i));
        return best;
}

//int main()
//{
        //int tt;
        //scanf("%d",&tt);
        //for(int ttn=0;ttn<tt;ttn++)
        //{
                //int n;
                //scanf("%d",&n);
                //vector f(n,vector<int>(n));
                //for(int i=0;i<n;i++) {
                        //for(int j=0;j<n;j++) {
                                //scanf(" %c",&f[i][j]);f[i][j]=f[i][j]=='1';
                        //}
                //}
                //printf("%d\n",biggest_stadium(n,f));
        //}
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB ok
2 Correct 2 ms 10588 KB ok
3 Correct 2 ms 10584 KB ok
4 Correct 2 ms 10588 KB ok
5 Correct 1 ms 10688 KB ok
6 Correct 1 ms 10688 KB ok
7 Correct 13 ms 15000 KB ok
8 Correct 1069 ms 31720 KB ok
9 Execution timed out 4558 ms 118100 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB ok
2 Correct 2 ms 10588 KB ok
3 Correct 2 ms 10584 KB ok
4 Correct 1 ms 10588 KB ok
5 Correct 2 ms 10588 KB ok
6 Correct 2 ms 10588 KB ok
7 Correct 2 ms 10588 KB ok
8 Correct 1 ms 10588 KB ok
9 Correct 2 ms 10588 KB ok
10 Correct 1 ms 10588 KB ok
11 Correct 2 ms 10584 KB ok
12 Correct 1 ms 10588 KB ok
13 Correct 2 ms 10588 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB ok
2 Correct 1 ms 10588 KB ok
3 Correct 2 ms 10588 KB ok
4 Correct 2 ms 10584 KB ok
5 Correct 1 ms 10588 KB ok
6 Correct 2 ms 10588 KB ok
7 Correct 2 ms 10588 KB ok
8 Correct 2 ms 10588 KB ok
9 Correct 1 ms 10588 KB ok
10 Correct 2 ms 10588 KB ok
11 Correct 1 ms 10588 KB ok
12 Correct 2 ms 10584 KB ok
13 Correct 1 ms 10588 KB ok
14 Correct 2 ms 10588 KB ok
15 Correct 2 ms 10588 KB ok
16 Correct 2 ms 10588 KB ok
17 Correct 1 ms 10588 KB ok
18 Correct 2 ms 10588 KB ok
19 Correct 2 ms 10588 KB ok
20 Correct 2 ms 10588 KB ok
21 Correct 2 ms 10588 KB ok
22 Correct 2 ms 10588 KB ok
23 Correct 1 ms 10588 KB ok
24 Correct 2 ms 10588 KB ok
25 Correct 2 ms 10588 KB ok
26 Correct 2 ms 10588 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB ok
2 Correct 1 ms 10588 KB ok
3 Correct 2 ms 10588 KB ok
4 Correct 2 ms 10584 KB ok
5 Correct 2 ms 10588 KB ok
6 Correct 2 ms 10584 KB ok
7 Correct 1 ms 10588 KB ok
8 Correct 2 ms 10588 KB ok
9 Correct 2 ms 10588 KB ok
10 Correct 2 ms 10588 KB ok
11 Correct 1 ms 10588 KB ok
12 Correct 2 ms 10588 KB ok
13 Correct 1 ms 10588 KB ok
14 Correct 2 ms 10584 KB ok
15 Correct 1 ms 10588 KB ok
16 Correct 2 ms 10588 KB ok
17 Correct 2 ms 10588 KB ok
18 Correct 2 ms 10588 KB ok
19 Correct 1 ms 10588 KB ok
20 Correct 2 ms 10588 KB ok
21 Correct 2 ms 10588 KB ok
22 Correct 2 ms 10588 KB ok
23 Correct 2 ms 10588 KB ok
24 Correct 2 ms 10588 KB ok
25 Correct 1 ms 10588 KB ok
26 Correct 2 ms 10588 KB ok
27 Correct 2 ms 10588 KB ok
28 Correct 2 ms 10588 KB ok
29 Correct 2 ms 10588 KB ok
30 Correct 3 ms 12636 KB ok
31 Correct 3 ms 12636 KB ok
32 Correct 3 ms 12888 KB ok
33 Correct 3 ms 12636 KB ok
34 Correct 3 ms 12636 KB ok
35 Correct 3 ms 12632 KB ok
36 Correct 3 ms 12632 KB ok
37 Correct 3 ms 12636 KB ok
38 Correct 3 ms 12852 KB ok
39 Correct 3 ms 12636 KB ok
40 Correct 3 ms 12636 KB ok
41 Correct 3 ms 12852 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB ok
2 Correct 1 ms 10588 KB ok
3 Correct 2 ms 10588 KB ok
4 Correct 2 ms 10584 KB ok
5 Correct 2 ms 10588 KB ok
6 Correct 2 ms 10584 KB ok
7 Correct 1 ms 10588 KB ok
8 Correct 2 ms 10588 KB ok
9 Correct 2 ms 10588 KB ok
10 Correct 2 ms 10588 KB ok
11 Correct 1 ms 10588 KB ok
12 Correct 2 ms 10588 KB ok
13 Correct 1 ms 10588 KB ok
14 Correct 2 ms 10584 KB ok
15 Correct 1 ms 10588 KB ok
16 Correct 2 ms 10588 KB ok
17 Correct 2 ms 10588 KB ok
18 Correct 2 ms 10588 KB ok
19 Correct 1 ms 10588 KB ok
20 Correct 2 ms 10588 KB ok
21 Correct 2 ms 10588 KB ok
22 Correct 2 ms 10588 KB ok
23 Correct 2 ms 10588 KB ok
24 Correct 2 ms 10588 KB ok
25 Correct 1 ms 10588 KB ok
26 Correct 2 ms 10588 KB ok
27 Correct 2 ms 10588 KB ok
28 Correct 2 ms 10588 KB ok
29 Correct 2 ms 10588 KB ok
30 Correct 3 ms 12636 KB ok
31 Correct 3 ms 12636 KB ok
32 Correct 3 ms 12888 KB ok
33 Correct 3 ms 12636 KB ok
34 Correct 3 ms 12636 KB ok
35 Correct 3 ms 12632 KB ok
36 Correct 3 ms 12632 KB ok
37 Correct 3 ms 12636 KB ok
38 Correct 3 ms 12852 KB ok
39 Correct 3 ms 12636 KB ok
40 Correct 3 ms 12636 KB ok
41 Correct 3 ms 12852 KB ok
42 Correct 1085 ms 31572 KB ok
43 Correct 1076 ms 31980 KB ok
44 Correct 1080 ms 31756 KB ok
45 Correct 1080 ms 31824 KB ok
46 Correct 1085 ms 31580 KB ok
47 Correct 1072 ms 31828 KB ok
48 Correct 1067 ms 31828 KB ok
49 Correct 1067 ms 31884 KB ok
50 Correct 1069 ms 31724 KB ok
51 Correct 1091 ms 31824 KB ok
52 Correct 1079 ms 31892 KB ok
53 Correct 1087 ms 31720 KB ok
54 Correct 1065 ms 31724 KB ok
55 Correct 1090 ms 31728 KB ok
56 Correct 1092 ms 31724 KB ok
57 Correct 1076 ms 31828 KB ok
58 Correct 1077 ms 31724 KB ok
59 Correct 1087 ms 31720 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10588 KB ok
2 Correct 1 ms 10588 KB ok
3 Correct 2 ms 10588 KB ok
4 Correct 2 ms 10584 KB ok
5 Correct 2 ms 10588 KB ok
6 Correct 1 ms 10688 KB ok
7 Correct 1 ms 10688 KB ok
8 Correct 13 ms 15000 KB ok
9 Correct 1069 ms 31720 KB ok
10 Execution timed out 4558 ms 118100 KB Time limit exceeded
11 Halted 0 ms 0 KB -