답안 #51533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51533 2018-06-18T07:28:55 Z MoesashiMinamoto The Kingdom of JOIOI (JOI17_joioi) C++14
0 / 100
3 ms 616 KB
#include <bits/stdc++.h>
#define int 	long long
using namespace std;

int h[4], w[4];
int a[4][2003][2003];
int mi;

void preproc()
{
	for(int t = 1; t < 4; t++)
	{
		h[t] = w[t-1];
		w[t] = h[t-1];
		for (int i = 1; i <= h[t-1]; i++)
		{
			for (int j = 1; j <= w[t-1]; j++)
			{
				a[t][j][h[t-1]-i+1] = a[t-1][i][j];
			}
		}
	}
}

bool chec(int k)
{
	for (int t = 0; t < 4; t++)
	{
		int lim, nexlim = w[t];
		int ma = -INT_MAX, mii = INT_MAX;
		for (int i = 1; i <= h[t]; i++)
		{
			lim = nexlim;
			for (int j = 1; j <= lim; j++)
			{
				if (a[t][i][j] <= mi + k)
				{
					continue;
				}
				else
				{
					nexlim = j;
					break;
				}
			}
			for (int j = lim+1; j <= w[t]; j++)
			{
				mii = min(mii, a[t][i][j]);
				ma = max(ma, a[t][i][j]);
			}	
		}
		//cout << ma << " " << mii << " " << t << " " << k << endl;
		if (ma - mii <= k) return true;
	}
	return false;
}

signed main()
{
	scanf("%lld%lld", &h[0], &w[0]);
	mi = INT_MAX;
	for (int i = 1; i <= h[0]; i++)
	{
		for (int j = 1; j <= w[0]; j++)
		{
			scanf("%lld", &a[0][i][j]);
			mi = min(mi, a[0][i][j]);
		}
	}	
	preproc();
	/*for (int t = 0; t < 4; t++)
	{
		for (int i = 1; i <= h[t]; i++)
		{
			for (int j = 1; j <= w[t]; j++)
			{
				printf ("%d ", a[t][i][j]);
			}
			printf("\n");
		}
		printf("\n");
	}*/
	int res = 0;
	for (int j = 31; j >= 0; j--)
	{
		if (res + (1ll << j) <= 1000000000)
		{
			int cur = res + (1ll << j);
			if (!chec(cur))
			{
				res = cur;
			}
		}
	}
	printf("%lld", res+1);
}

Compilation message

joioi.cpp: In function 'int main()':
joioi.cpp:60:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &h[0], &w[0]);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
joioi.cpp:66:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld", &a[0][i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 616 KB Output is correct
3 Incorrect 3 ms 616 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 616 KB Output is correct
3 Incorrect 3 ms 616 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 616 KB Output is correct
3 Incorrect 3 ms 616 KB Output isn't correct
4 Halted 0 ms 0 KB -