Submission #1267539

#TimeUsernameProblemLanguageResultExecution timeMemory
1267539ti24dung_nt삶의 질 (IOI10_quality)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "grader.h"
#include "quality.h"

int rectangle(int row, int col, int hig, int wid, int q[][3002])
{
    int l = 1e10, r = -1e10;
    for(int i = 0; i < row; ++i)
    {
        for(int j = 0; j < col; ++j)
        {
            l = min(l, q[i][j]); r = max(r, q[i][j]);
        }
    }

    int a[3002][3002], sum[3002][3002], ans;
    while(l <= r)
    {
        int mid = (l + r) / 2;

        for(int i = 1; i <= row; ++i)
        {
            for(int j = 1; j <= col; ++j)
            {
                if(q[i - 1][j - 1] <= mid) a[i][j] = 1;
                else a[i][j] = -1;
            }
        }

        sum[0][0] = 0;
        for(int i = 1; i <= row; ++i) sum[i][0] = 0;
        for(int j = 1; j <= col; ++j) sum[0][j] = 0;

        for(int i = 1; i <= row; ++i)
        {
            for(int j = 1; j <= col; ++j)
            {
                sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
            }
        }

        bool check = false;
        for(int x1 = 1; x1 <= row - hig + 1; ++x1)
        {
            for(int y1 = 1; y1 <= col - wid + 1; ++y1)
            {
                int x2 = x1 + hig - 1, y2 = y1 + wid - 1;
                int res = sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
                if(res > 0) check = true;
                if(check) break;
            }
            if(check) break;
        }

        if(check)
        {
            ans = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }

    return ans;

}

Compilation message (stderr)

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3002])':
quality.cpp:7:13: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow]
    7 |     int l = 1e10, r = -1e10;
      |             ^~~~
quality.cpp:7:23: warning: overflow in conversion from 'double' to 'int' changes value from '-1.0e+10' to '-2147483648' [-Woverflow]
    7 |     int l = 1e10, r = -1e10;
      |                       ^~~~~
quality.cpp:12:17: error: 'min' was not declared in this scope
   12 |             l = min(l, q[i][j]); r = max(r, q[i][j]);
      |                 ^~~
quality.cpp:12:17: note: suggested alternatives:
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from quality.cpp:1:
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   'std::min'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/13/bits/ranges_algo.h:39,
                 from /usr/include/c++/13/algorithm:63:
/usr/include/c++/13/bits/ranges_util.h:738:29: note:   'std::ranges::min'
  738 |   inline constexpr __min_fn min{};
      |                             ^~~
quality.cpp:12:38: error: 'max' was not declared in this scope
   12 |             l = min(l, q[i][j]); r = max(r, q[i][j]);
      |                                      ^~~
quality.cpp:12:38: note: suggested alternatives:
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   'std::max'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/ranges_algo.h:2928:29: note:   'std::ranges::max'
 2928 |   inline constexpr __max_fn max{};
      |                             ^~~