Submission #853707

# Submission time Handle Problem Language Result Execution time Memory
853707 2023-09-25T04:45:09 Z vjudge1 Quality Of Living (IOI10_quality) C++
Compilation error
0 ms 0 KB
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int r, c, h, w, a[3010][3010], s[3010][3010];
bool check(int x)
{
	for(int i = 1; i <= r; i++)
	{
		for(int j = 1; j <= c; j++)
		{
			s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (a[i][j] > x);
			
		}
	}
	for(int i = h; i <= r; i++)
	{
		for(int j = w; j <= c; j++)
		{
			if(s[i][j] - s[i - h][j] - s[i][j - w] + s[i - h][j - w] <= h * w / 2)
				return true;
		}
	}
	return false;
}
inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while(ch >= '0' && ch <= '9')
	{
		x = (x << 1) + (x << 3) + ch ^ 48;
		ch = getchar();
	}
	return x;
}
int main()
{
	r = read(), c = read(), h = read(), w = read();
	for(int i = 1; i <= r; i++)
	{
		for(int j = 1; j <= c; j++)
		{
			a[i][j] = read();
		}
	}
	int L = 1, R = r * c;
	while(L < R)
	{
		int mid = (L + R) >> 1;
		if(check(mid)) R = mid;
		else L = mid + 1;
	}
	printf("%d", L);
	return 0;
}

Compilation message

quality.cpp: In function 'int read()':
quality.cpp:32:27: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   32 |   x = (x << 1) + (x << 3) + ch ^ 48;
      |       ~~~~~~~~~~~~~~~~~~~~^~~~
quality.cpp:28:13: warning: unused variable 'f' [-Wunused-variable]
   28 |  int x = 0, f = 1;
      |             ^
/usr/bin/ld: /tmp/ccjd6wsE.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccwZhWiG.o:quality.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccjd6wsE.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