UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211139#3801. Thief Masters18915523188Compile Error//C++1.9kb2024-08-09 12:20:202024-08-09 12:56:07

answer

#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimeze(2)
using namespace std;
ll a,b,n,num[5005][5005],ma,mi,maa[5005][5005],mia[5005][5005],ans=1145141919810,la,ra,li,ri;
struct s{
	ll x,ta;
}qa[5005],qi[5005];

void fff(){
	for(int i=1;i<=a-n+1;i++){
    	for(int j=1;j<=b-n+1;j++){
    		ma=-1;
    		mi=1145141919810;
    		for(int x=0;x<n;x++){
    			for(int y=0;y<n;y++){
    				if(ma<num[x][y]){
    					ma=num[x][y];
					}if(mi>num[x][y]){
						mi=num[x][y];
					}
				}
			}
			if(ans>ma-mi){
				ans=ma-mi;
			}
		}
	}
	cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    cin>>a>>b>>n;
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			cin>>num[i][j];
		}
	}
    if(a<=100&&b<=100&&n<=10){
    	fff();
    	return 0;
	}
	la=1;
	ra=0;
	li=1;
	ri=0;
    for(int i=1;i<=a;i++){
    	for(int j=1;j<=b;j++){
    		while(la<=ra&&qa[r].x<num[i][j]){
    			ra--;
			}
			ra++;
			qa[ra].x=num[i][j];
			qa[ra].ta=j;
			if(j>n){
				if(qa[l].ta<=j-n){
					la++;
				}
				maa[i][j]=qa[la].x;
			}
			
			while(li<=ri&&qi[r].x>num[i][j]){
    			ri--;
			}
			ri++;
			qi[ri].x=num[i][j];
			qi[ri].ti=j;
			if(j>=n){
				if(qi[li].ta<=j-n){
					l++;
				}
				mia[i][j]=qi[li].x;
			}
		}
	}
	
	for(int i=n;i<=b;i++){
    	for(int j=1;j<=a;j++){
    		while(la<=ra&&qa[r].x<maa[j][i]){
    			ra--;
			}
			ra++;
			qa[ra].x=maa[i][j];
			qa[ra].ta=j;
			if(j>n){
				if(qa[l].ta<=j-n){
					la++;
				}
				mia[j][i]=qa[la].x;
			}
			
			while(li<=ri&&qi[r].x<mia[j][i]){
    			ri--;
			}
			ri++;
			qi[ri].x=mia[j][i];
			qi[ri].ta=j;
			if(j>n){
				if(qi[li].ta<=j-n){
					l++;
				}
				mia[j][i]=qi[li].x;
			}
		}
	}
	for(int i=n;i<=a;i++){
		for(int j=n;j<=b;j++){
			if(ans>maa[i][j]-mia[i][j]){
				ans=maa[i][j]-mia[i][j];
			}
		}
	}
    
    cout<<ans;
    return 0;
}

详细

answer.code: In function 'int main()':
answer.code:53:24: error: 'r' was not declared in this scope
       while(la<=ra&&qa[r].x<num[i][j]){\x0d
                        ^
answer.code:60:11: error: 'l' was not declared in this scope
     if(qa[l].ta<=j-n){\x0d
           ^
answer.code:66:21: error: 'r' was not declared in this scope
    while(li<=ri&&qi[r].x>num[i][j]){\x0d
                     ^
answer.code:71:11: error: 'struct s' has no member named 'ti'
    qi[ri].ti=j;\x0d
           ^
answer.code:74:6:...