Submission #1038403

#TimeUsernameProblemLanguageResultExecution timeMemory
1038403fv3Soccer Stadium (IOI23_soccer)C++17
12 / 100
4580 ms97404 KiB

#include "soccer.h"
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
vector<vector<int>> ps_h, ps_v;

int biggest_stadium(int N, vector<vector<int>> F)
{
    int res = 0;
 
    ps_h = ps_v = vector<vector<int>>(N, vector<int>(N+1));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            ps_h[i][j + 1] = ps_h[i][j] + F[i][j];
            ps_v[i][j + 1] = ps_v[i][j] + F[j][i];
        }
    }

    vector<pair<int, int>> vpi;
    for (int y = 0; y < N; y++)
    {
        for (int x = 0; x < N; x++)
        {
            if (!F[y][x])
                vpi.push_back({x, y});
        }
    }
 
    for (int i = 0; i < vpi.size(); i++)
    {
        int x, y;
        tie(x, y) = vpi[i];
 
        for (int j = i+1; j < vpi.size(); j++)
        {
            int nx, ny;
            tie(nx, ny) = vpi[j];
 
            bool b1 = (ps_v[x][max(y, ny) + 1] - ps_v[x][min(y, ny)] > 0 || ps_h[ny][max(x, nx) + 1] - ps_h[ny][min(x, nx)] > 0);   
            bool b2 = (ps_v[nx][max(y, ny) + 1] - ps_v[nx][min(y, ny)] > 0 || ps_h[y][max(x, nx) + 1] - ps_h[y][min(x, nx)] > 0);   

            //cout << "(" << x << ", " << y << ") + (" << nx  << ", " << ny << ") = " << b1 << ", " << b2 << '\n'; 

            if (b1 && b2)
                return -1;
        }
    }
 
    return vpi.size();
}

Compilation message (stderr)

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i = 0; i < vpi.size(); i++)
      |                     ~~^~~~~~~~~~~~
soccer.cpp:39:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (int j = i+1; j < vpi.size(); j++)
      |                           ~~^~~~~~~~~~~~
soccer.cpp:12:9: warning: unused variable 'res' [-Wunused-variable]
   12 |     int res = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...