Submission #846501

# Submission time Handle Problem Language Result Execution time Memory
846501 2023-09-07T16:16:21 Z Andrey Soccer Stadium (IOI23_soccer) C++17
6 / 100
433 ms 105976 KB
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;

int haha[3001][3001];
int l[3001][3001];
int r[3001][3001];
int n;

vector<int> lol(3001);

void calc(const vector<int>& haha) {
    int n = haha.size();
    vector<int> bruh(n);
    vector<int> wow(n);
    stack<pair<int,int>> idk;
    for(int i = 0; i < n; i++) {
        int a = haha[i];
        while(!idk.empty() && a <= idk.top().first) {
            idk.pop();
        }
        if(idk.empty()) {
            bruh[i] = (i+1)*a;
        }
        else {
            bruh[i] = bruh[idk.top().second]+a*(i-idk.top().second);
        }
        idk.push({a,i});
    }
    while(!idk.empty()) {
        idk.pop();
    }
    for(int i = n-1; i >= 0; i--) {
        int a = haha[i];
        while(!idk.empty() && a <= idk.top().first) {
            idk.pop();
        }
        if(idk.empty()) {
            wow[i] = (n-i)*a;
        }
        else {
            wow[i] = wow[idk.top().second]+a*(idk.top().second-i);
        }
        idk.push({a,i});
    }
    for(int i = 0; i < n; i++) {
        lol[i]+=bruh[i]+wow[i]-haha[i];
    }
}

int biggest_stadium(int N, std::vector<std::vector<int>> f)
{
    n = N;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            haha[i][j] = f[i][j];
        }
    }
    for(int i = 0; i < n; i++) {
        if(haha[i][0]) {
            l[i][0] = -1;
        }
        else {
            l[i][0] = 0;
        }
        for(int j = 1; j < n; j++) {
            if(haha[i][j]) {
                l[i][j] = -1;
            }
            else {
                l[i][j] = l[i][j-1]+1;
            }
        }
        if(haha[i][n-1]) {
            r[i][n-1] = -1;
        }
        else {
            r[i][n-1] = 0;
        }
        for(int j = n-2; j >= 0; j--) {
            if(haha[i][j]) {
                r[i][j] = -1;
            }
            else {
                r[i][j] = r[i][j+1]+1;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        vector<int> yay(0);
        vector<int> wut(0);
        for(int j = 0; j < n; j++) {
            if(l[j][i] == -1) {
                if(yay.size() > 0) {
                    for(int z = 0; z < wut.size(); z++) {
                        lol[z] = 0;
                    }
                    calc(yay);
                    calc(wut);
                    for(int z = 0; z < wut.size(); z++) {
                        ans = max(ans,(int)wut.size()+lol[z]);
                    }
                }
                yay.clear();
                wut.clear();
            }
            else {
                yay.push_back(l[j][i]);
                wut.push_back(r[j][i]);
            }
        }
        if(yay.size() > 0) {
            for(int z = 0; z < wut.size(); z++) {
                lol[z] = 0;
            }
            calc(yay);
            calc(wut);
            for(int z = 0; z < wut.size(); z++) {
                ans = max(ans,(int)wut.size()+lol[z]);
            }
        }
    }
    return ans;
}

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:96:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |                     for(int z = 0; z < wut.size(); z++) {
      |                                    ~~^~~~~~~~~~~~
soccer.cpp:101:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  101 |                     for(int z = 0; z < wut.size(); z++) {
      |                                    ~~^~~~~~~~~~~~
soccer.cpp:114:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  114 |             for(int z = 0; z < wut.size(); z++) {
      |                            ~~^~~~~~~~~~~~
soccer.cpp:119:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  119 |             for(int z = 0; z < wut.size(); z++) {
      |                            ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB ok
2 Correct 1 ms 4444 KB ok
3 Correct 1 ms 4444 KB ok
4 Correct 1 ms 4444 KB ok
5 Correct 1 ms 4444 KB ok
6 Correct 1 ms 4444 KB ok
7 Correct 2 ms 6748 KB ok
8 Correct 28 ms 23052 KB ok
9 Correct 433 ms 105976 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB ok
2 Correct 1 ms 4444 KB ok
3 Correct 1 ms 4444 KB ok
4 Correct 1 ms 4444 KB ok
5 Correct 1 ms 4444 KB ok
6 Correct 1 ms 4444 KB ok
7 Incorrect 1 ms 4444 KB wrong
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB ok
2 Correct 1 ms 4444 KB ok
3 Correct 1 ms 4444 KB ok
4 Correct 1 ms 4444 KB ok
5 Correct 1 ms 4444 KB ok
6 Correct 1 ms 4444 KB ok
7 Correct 1 ms 4444 KB ok
8 Incorrect 1 ms 4444 KB wrong
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB ok
2 Correct 1 ms 4444 KB ok
3 Correct 1 ms 4444 KB ok
4 Correct 1 ms 4444 KB ok
5 Correct 1 ms 4444 KB ok
6 Correct 1 ms 4444 KB ok
7 Correct 1 ms 4444 KB ok
8 Correct 1 ms 4444 KB ok
9 Correct 1 ms 4444 KB ok
10 Incorrect 1 ms 4444 KB wrong
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB ok
2 Correct 1 ms 4444 KB ok
3 Correct 1 ms 4444 KB ok
4 Correct 1 ms 4444 KB ok
5 Correct 1 ms 4444 KB ok
6 Correct 1 ms 4444 KB ok
7 Correct 1 ms 4444 KB ok
8 Correct 1 ms 4444 KB ok
9 Correct 1 ms 4444 KB ok
10 Incorrect 1 ms 4444 KB wrong
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB ok
2 Correct 1 ms 4444 KB ok
3 Correct 1 ms 4444 KB ok
4 Correct 1 ms 4444 KB ok
5 Correct 1 ms 4444 KB ok
6 Correct 1 ms 4444 KB ok
7 Correct 1 ms 4444 KB ok
8 Correct 2 ms 6748 KB ok
9 Correct 28 ms 23052 KB ok
10 Correct 433 ms 105976 KB ok
11 Correct 1 ms 4444 KB ok
12 Correct 1 ms 4444 KB ok
13 Correct 1 ms 4444 KB ok
14 Correct 1 ms 4444 KB ok
15 Incorrect 1 ms 4444 KB wrong
16 Halted 0 ms 0 KB -