UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213837#2406. Thief Mastersckliang101598ms332488kbC++111.4kb2024-11-13 21:26:062024-11-13 23:08:13

answer

#include<bits/stdc++.h>

using namespace std;
const int N=1010,M=12;
int s[N][N];
int st[N][M][N][M][2];
int lg2[N];
int n,m,l;
int main()
{
	cin>>n>>m>>l;
	for( int i=2 ; i<N ; i++ )lg2[i]=lg2[i/2]+1;
	for( int i=1 ; i<=n ; i++ )
	{
		for( int j=1 ; j<=m ; j++ )
		{
			cin>>s[i][j];
			st[i][0][j][0][0]=s[i][j];
			st[i][0][j][0][1]=s[i][j];
		}
	}
	for( int i=1 ; i<=n ; i++ )
	{
		for( int k1=1 ; (1<<k1)<=l ; k1++ )
		{
			for( int j=1 ; j+(1<<k1)-1<=m ; j++ )
			{
				for( int k2=1 ; (1<<k2)<=l && i+(1<<k2)-1<=n ; k2++ )
				{
					st[i][k1][j][k2][0]=min(
					min(st[i][k1-1][j][k2-1][0],st[i+(1<<(k1-1))][k1-1][j][k2-1][0]),
					min(st[i][k1-1][j+(1<<(k2-1))][k2-1][0],st[i+(1<<(k1-1))][k1-1][j+(1<<(k2-1))][k2-1][0])
					);
					st[i][k1][j][k2][1]=max(
					max(st[i][k1-1][j][k2-1][1],st[i+(1<<(k1-1))][k1-1][j][k2-1][1]),
					max(st[i][k1-1][j+(1<<(k2-1))][k2-1][1],st[i+(1<<(k1-1))][k1-1][j+(1<<(k2-1))][k2-1][1])
					);
				}
			}
		}
	}
	int ans=1e9+7,i2,j2,x=lg2[l],d=1<<(lg2[l]);
	for( int i=1 ; i+l-1<=n ; i++ )
	{
		for( int j=1 ; j+l-1<=m ; j++ )
		{
			i2=i+l-1;
			j2=j+l-1;
			ans=min(ans,
			max(
			max(st[i][x][j][x][1],st[i2-d+1][x][j][x][1]),
			max(st[i][x][j2-d+1][x][1],st[i2-d+1][x][j2-d+1][x][1])
			)-
			min(
			min(st[i][x][j][x][0],st[i2-d+1][x][j][x][0]),
			min(st[i][x][j2-d+1][x][0],st[i2-d+1][x][j2-d+1][x][0])
			)
			);
		}
	}
	cout<<ans<<endl;
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Time Limit Exceeded

input:

1000 1000 100
804544523 340648618 718292412 235345736 704741136 942776831 741228920 463473302 677289...

output:


result:


Test #2:

score: 10
Accepted
time: 0ms
memory: 1264kb

input:

5 4 2
1 2 5 6
0 17 16 0
16 17 0 1
2 10 2 1
1 2 3 2

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Wrong Answer
time: 11ms
memory: 6752kb

input:

100 100 10
2 100001 200001 300001 400001 500001 600001 700001 800001 900001 1000001 1100001 1200001 ...

output:

903001

result:

wrong answer 1st lines differ - expected: '908999', found: '903001'

Test #4:

score: 0
Time Limit Exceeded

input:

1000 1000 20
1 100001 200001 300001 400001 500001 600001 700001 800001 900001 1000001 1100001 120000...

output:


result:


Test #5:

score: 0
Wrong Answer
time: 246ms
memory: 152672kb

input:

500 500 50
79289095 232165705 955620938 481434262 465576217 112035388 50089892 459799006 181906335 3...

output:

950224833

result:

wrong answer 1st lines differ - expected: '995944328', found: '950224833'

Test #6:

score: 0
Wrong Answer
time: 375ms
memory: 332488kb

input:

500 1000 80
499163842 331022295 940054497 684192083 248823911 842132608 629298697 398526298 98438040...

output:

957664569

result:

wrong answer 1st lines differ - expected: '998299092', found: '957664569'

Test #7:

score: 0
Memory Limit Exceeded

input:

1000 1000 80
102 134 429 251 299 109 264 669 727 296 112 550 270 270 544 660 131 546 968 219 113 678...

output:


result:


Test #8:

score: 0
Wrong Answer
time: 305ms
memory: 175124kb

input:

500 500 100
65532583 920409544 753795976 989349545 818384831 778207112 425141881 853270293 542112588...

output:

972905121

result:

wrong answer 1st lines differ - expected: '999172505', found: '972905121'

Test #9:

score: 0
Wrong Answer
time: 661ms
memory: 332488kb

input:

500 1000 100
456896744 779471086 578349238 52507342 192194992 156396237 475084995 775765435 96617474...

output:

975774957

result:

wrong answer 1st lines differ - expected: '998801667', found: '975774957'

Test #10:

score: 0
Memory Limit Exceeded

input:

1000 1000 100
629053044 957239666 456746076 940194386 201529807 592062148 244394389 825620014 223976...

output:


result: