제출 #1370712

#제출 시각아이디문제언어결과실행 시간메모리
1370712huangallen축구 경기장 (IOI23_soccer)C++20
6 / 100
251 ms251904 KiB
#include "soccer.h"
#ifdef LOCAL
#include "grader.cpp"
#endif
#include<bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,sse4,bmi2,popcnt")
#define int long long
#define iint signed
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define RREP1(i,n) for(int i=(n);i>=1;i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)((x).size()))
#define SQ(x) ((x)*(x))
#define pii pair<int,int>
#define pipii pair<int,pii>
#define ppi pair<pii,int>
#define Graph vector<vector<int>>
#define Graphw vector<vector<pii>>
#define IOS() ios::sync_with_stdio(0),cin.tie(0)
#define md(x) (((x)%(mod)+(mod))%(mod))
#define MD(x,M) (((x)%(M)+(M))%(M))
#define ld long double
#define pdd pair<ld,ld>
template<typename S> void chmin(S &x,S y) { x=min(x,y); }
template<typename S> void chmax(S &x,S y) { x=max(x,y); }
#define addmod(x,y) x=((x+(y))%mod)
#define Vi vector<int>
#define Vpii vector<pii>
#ifdef LOCAL
#define op(x) cout<<(#x)<<"="<<(x)<<", ";
#define ope(x) cout<<(#x)<<"="<<(x)<<endl;
#define oparr(x) {cout<<(#x)<<":";for(auto allen:(x)) cout<<allen<<" ";cout<<" size="<<(x).size()<<endl;}
#define entr cout<<endl;
#else
#define op(x) ;
#define ope(x) ;
#define oparr(x) ;
#define entr ;
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& os,pair<T1,T2> p) { return os<<'{'<<p.f<<','<<p.s<<'}'; }
template<typename T1,typename T2>
istream& operator>>(istream& os,pair<T1,T2> &p) { return os>>p.f>>p.s; }
template<typename S>
ostream& operator<<(ostream& os,vector<S> p) { for(auto allen:p) os<<allen<<' ';return os<<'\n'; }
template<typename S>
istream& operator>>(istream& os,vector<S> &p) { for(auto &allen:p) os>>allen;return os; }
template<typename T1,typename T2>
pair<T1,T2> operator+(pair<T1,T2> p1,pair<T1,T2> p2) { return pair<T1,T2>(p1.f+p2.f,p1.s+p2.s); }
const int mod=998244353;
const int maxn=1e5+5;
const int maxv=1e6+5;
const int inf=1ll<<60;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rd(int l,int r) {
    return uniform_int_distribution<int>(l,r)(rng);
}
iint biggest_stadium(iint N, std::vector<std::vector<iint>> F)
{
    int n=N;
    vector<Vi> a(n+2,Vi(n+2));
    REP1(i,n) REP1(j,n) a[i][j]=F[i-1][j-1];
    vector<Vi> u(n+2,Vi(n+2));
    vector<Vi> d(n+2,Vi(n+2));
    REP1(i,n) REP1(j,n) u[i][j]=a[i][j]==0?u[i-1][j]+1:0;
    RREP1(i,n) REP1(j,n) d[i][j]=a[i][j]==0?d[i+1][j]+1:0;
    vector<Vi> ul(n+2,Vi(n+2));
    vector<Vi> ur(n+2,Vi(n+2));
    vector<Vi> dl(n+2,Vi(n+2));
    vector<Vi> dr(n+2,Vi(n+2));
    oparr(u)
    REP1(i,n) {
        {
            Vpii stk;
            stk.pb({0,0});
            int sum=0;
            REP1(j,n) {
                while(u[i][j]<stk.back().f) {
                    sum-=stk.back().f*(stk.back().s-stk[SZ(stk)-2].s);
                    stk.pop_back();
                }
                sum+=u[i][j]*(j-stk.back().s);
                stk.pb({u[i][j],j});
                ul[i][j]=sum;
            }
        }
        {
            Vpii stk;
            stk.pb({0,n+1});
            int sum=0;
            RREP1(j,n) {
                while(u[i][j]<stk.back().f) {
                    sum+=stk.back().f*(stk.back().s-stk[SZ(stk)-2].s);
                    stk.pop_back();
                }
                sum-=u[i][j]*(j-stk.back().s);
                stk.pb({u[i][j],j});
                ur[i][j]=sum;
            }
        }
        {
            Vpii stk;
            stk.pb({0,0});
            int sum=0;
            REP1(j,n) {
                while(d[i][j]<stk.back().f) {
                    sum-=stk.back().f*(stk.back().s-stk[SZ(stk)-2].s);
                    stk.pop_back();
                }
                sum+=d[i][j]*(j-stk.back().s);
                stk.pb({d[i][j],j});
                dl[i][j]=sum;
            }
        }
        {
            Vpii stk;
            stk.pb({0,n+1});
            int sum=0;
            RREP1(j,n) {
                while(d[i][j]<stk.back().f) {
                    sum+=stk.back().f*(stk.back().s-stk[SZ(stk)-2].s);
                    stk.pop_back();
                }
                sum-=d[i][j]*(j-stk.back().s);
                stk.pb({d[i][j],j});
                dr[i][j]=sum;
            }
        }
    }
    int an=0;
    REP1(i,n) REP1(j,n) chmax(an,ul[i][j]+ur[i][j+1]+dl[i+1][j]+dr[i+1][j+1]);
    // oparr(ul)
    return an;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…