Submission #349641

# Submission time Handle Problem Language Result Execution time Memory
349641 2021-01-18T05:21:48 Z eric00513 Quality Of Living (IOI10_quality) C++
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX = 3003;

int a[MAX][MAX], r, c, h, w;
int t[MAX][MAX], pfx[MAX][MAX];

int getval(int x) { return x ? x / abs(x) : 0; }

int check(int x)
{
	int i, j;

	for (i = 1; i <= r; i++)
		for (j = 1; j <= c; j++)
			t[i][j] = getval(a[i][j]);

	for (i = 1; i <= r; i++)
		for (j = 1; j <= c; j++)
			pfx[i][j] = pfx[i - 1][j] + pfx[i][j - 1] - pfx[i - 1][j - 1] + t[i][j];

	for (i = 1; i <= r - (h - 1); i++)
		for (j = 1; j <= c - (w - 1); j++)
		{
			int ki = i + h - 1, kj = j + w - 1;
            int val = pfx[ki][kj] - pfx[ki][j - 1] - pfx[i - 1][kj] + pfx[i - 1][j - 1];

            if (val == 0)
                return 0;
            else if (val < 0)
                return -1;
		}

	return 1;
}

int main(void)
{
	int i, j;

	scanf("%d %d %d %d", &r, &c, &h, &w);

	for (i = 1; i <= r; i++)
		for (j = 1; j <= c; j++)
			scanf("%d", &a[i][j]);

    int lo = 1, hi = r * c, mid;

	while (true)
	{
		mid = (lo + hi) / 2;
        int res = check(mid);

        if (res == 0)
            break;
		if (res == 1)
			lo = mid + 1;
		else
			hi = mid - 1;
	}

	printf("%d", mid);
	return 0;
}

Compilation message

quality.cpp: In function 'int main()':
quality.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   42 |  scanf("%d %d %d %d", &r, &c, &h, &w);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
quality.cpp:46:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |    scanf("%d", &a[i][j]);
      |    ~~~~~^~~~~~~~~~~~~~~~
/tmp/ccgqMfjf.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccRgphxX.o:quality.cpp:(.text.startup+0x0): first defined here
/tmp/ccgqMfjf.o: In function `main':
grader.cpp:(.text.startup+0xe9): undefined reference to `rectangle(int, int, int, int, int (*) [3001])'
collect2: error: ld returned 1 exit status