답안 #856960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856960 2023-10-05T01:59:03 Z pirhosig 축구 경기장 (IOI23_soccer) C++17
6 / 100
397 ms 63060 KB
#include "soccer.h"
#include <bits/stdc++.h>
#define  R(a) for (int i = 0; i < a; ++i)
#define RR(a) for (int j = 0; j < a; ++j)
using namespace std;
typedef pair<int, int> ii;


int biggest_stadium(int N, vector<vector<int>> F)
{
    ii lrv[N][N];
    RR(N) {
        int lv = -1;
        R(N) {
            if (F[i][j]) lrv[i][j].first = (lv = -1);
            else {
                if (lv == -1) lv = i;
                lrv[i][j].first = lv;
            }
        }
        lv = -1;
        for (int i = N - 1; i >= 0; --i) {
            if (F[i][j]) lrv[i][j].second = (lv = -1);
            else {
                if (lv == -1) lv = i;
                lrv[i][j].second = lv;
            }
        }
    }

    // R(N) {
    //     RR(N) {
    //         if (!F[i][j]) cout << i << " " << j << " " << lrv[i][j].first << " " << lrv[i][j].second << endl;
    //     }
    // }

    int large = 0;
    R(N) {
        ii val1[N]{};
        stack<ii> stl, str;
        int tot = 0;
        RR(N) {
            if (F[i][j]) {
                if (stl.size()) stl = stack<ii>();
                if (str.size()) str = stack<ii>();
                tot = 0;
                continue;
            }
            val1[j].first = tot;
            int lv = lrv[i][j].first;
            int rv = lrv[i][j].second;
            while (stl.size() && stl.top().first < lv) {
                tot -= (lv - stl.top().first) * (j - stl.top().second);
                stl.pop();
            }
            if (stl.empty() || stl.top().first > lv) stl.push({lv, j});

            while (str.size() && str.top().first > rv) {
                tot -= (str.top().first - rv) * (j - str.top().second);
                str.pop();
            }
            if (str.empty() || str.top().first < rv) str.push({rv, j});

            val1[j].second = tot;
            tot += rv - lv + 1;
        }

        ii val2[N]{};
        tot = 0;
        stl = stack<ii>();
        str = stack<ii>();
        for (int j = N - 1; j >= 0; --j) {
            if (F[i][j]) {
                if (stl.size()) stl = stack<ii>();
                if (str.size()) str = stack<ii>();
                tot = 0;
                continue;
            }
            val2[j].first = tot;
            int lv = lrv[i][j].first;
            int rv = lrv[i][j].second;
            while (stl.size() && stl.top().first < lv) {
                tot -= (lv - stl.top().first) * (stl.top().second - j);
                stl.pop();
            }
            if (stl.empty() || stl.top().first > lv) stl.push({lv, j});

            while (str.size() && str.top().first > rv) {
                tot -= (str.top().first - rv) * (str.top().second - j);
                str.pop();
            }
            if (str.empty() || str.top().first < rv) str.push({rv, j});

            val2[j].second = tot;
            tot += rv - lv + 1;
        }

        RR(N) if (!F[i][j]) {
            int siz = max(val1[j].first + val2[j].second, val1[j].second + val2[j].first) + lrv[i][j].second - lrv[i][j].first + 1;
            // cout << i << " " << j << " " << siz << " " << val1[j] << " " << val2[j] << endl;
            large = max(large, siz);
        }
    }
    
    return large;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 504 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 Correct 0 ms 348 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 21 ms 4188 KB ok
9 Correct 397 ms 63060 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 504 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Incorrect 0 ms 348 KB wrong
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 504 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Incorrect 0 ms 348 KB wrong
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 504 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 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Incorrect 0 ms 348 KB wrong
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 504 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 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Incorrect 0 ms 348 KB wrong
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 504 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 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 21 ms 4188 KB ok
10 Correct 397 ms 63060 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Incorrect 0 ms 348 KB wrong
14 Halted 0 ms 0 KB -