Submission #850574

# Submission time Handle Problem Language Result Execution time Memory
850574 2023-09-16T23:49:21 Z resting Soccer Stadium (IOI23_soccer) C++17
6 / 100
326 ms 32220 KB
#include <bits/stdc++.h>
using namespace std;
//#include "soccer.h"

#define int long long

vector<int> monostack(vector<int> h){
    vector<int> res = {0};
    vector<int> x = {-1}, y;
    int cur = 0;
    for(int i = 0; i < h.size(); i++){
        while(y.size() && h[i] >= y.back()){
            cur -= y.back() * (x.back() - x[x.size()-2]);
            y.pop_back();
            x.pop_back();
        }
        cur += h[i] * (i - x.back());
        y.push_back(h[i]);
        x.push_back(i);
        res.push_back(cur);
    }
    return res; // is this really the easiest way
    //ill have to perfect it 
}

int32_t biggest_stadium(int32_t N, std::vector<std::vector<int32_t>> F)
{
    vector<vector<int>> u(N, {-1}), d(N, {N});
    for(int i = N-1; i >= 0; i--){
        for(int j = 0; j < N; j++){
            if(F[i][j] == 1){
                d[j].push_back(i);
            }
        }
    }
    int ans = N * N;
    for(int i = 0; i <= N; i++){
        vector<int> a;
        for(int j = 0; j < N; j++)a.push_back(u[j].back()+1);
        vector<int> b=  monostack(a);
        reverse(a.begin(), a.end());
        vector<int> c=  monostack(a);

        vector<int> e;
        for(int j = 0; j < N; j++) e.push_back(N - d[j].back());
        vector<int> f = monostack(e);
        reverse(e.begin(), e.end());
        vector<int> g= monostack(e);

        for(int j = 0; j <= N; j++){
            int tmp = b[j] + c[N-j] + f[j] + g[N-j];
            ans = min(ans, tmp);
        }

        for(int j = 0; j < N; j++){
            if(d[j].back() == i){
                d[j].pop_back();
                u[j].push_back(i);
            }
        }
    }
    return N * N - ans;
}

Compilation message

soccer.cpp: In function 'std::vector<long long int> monostack(std::vector<long long int>)':
soccer.cpp:11:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i = 0; i < h.size(); i++){
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 372 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 344 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 20 ms 2396 KB ok
9 Correct 326 ms 32220 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 372 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 348 KB ok
5 Incorrect 0 ms 348 KB wrong
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB ok
2 Correct 0 ms 372 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 1 ms 348 KB ok
6 Incorrect 0 ms 348 KB wrong
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB ok
2 Correct 0 ms 372 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 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 Incorrect 0 ms 348 KB wrong
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB ok
2 Correct 0 ms 372 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 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 Incorrect 0 ms 348 KB wrong
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB ok
2 Correct 0 ms 372 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 344 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 20 ms 2396 KB ok
10 Correct 326 ms 32220 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 1 ms 348 KB ok
13 Incorrect 0 ms 348 KB wrong
14 Halted 0 ms 0 KB -