#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,x,y,h[1111111],k;
void up()
{
int kkg=k;
while(kkg>1&&h[kkg]<h[kkg/2])
{
h[0]=h[kkg];
h[kkg]=h[kkg/2];
h[kkg/2]=h[0];
kkg/=2;
}
}
void down()
{
int kkgx=1,kkgy=2;
while((kkgy<=k&&h[kkgy]<h[kkgx])||(kkgy+1<=k&&h[kkgy+1]<h[kkgx]))
{
if(kkgy+1<=k&&h[kkgy+1]<h[kkgy]) kkgy++;
h[0]=h[kkgx];
h[kkgx]=h[kkgy];
h[kkgy]=h[0];
kkgx=kkgy;
kkgy*=2;
}
}
void add(int xxx)
{
k++;
h[k]=xxx;
up();
}
void pop(int xxx)
{
h[0]=h[xxx];
h[xxx]=h[k];
h[k]=h[0];
k--;
down();
}
int get()
{
return h[1];
}
int main()
{
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)
{
scanf("%d",&x);
add(x);
}
for(i=1;i<=m;i++)
{
scanf("%d",&x);
if(x==1)
{
scanf("%d",&y);
add(y);
}
else if(x==2)
{
printf("%d\n",get());
}
else if(x==3)
{
pop(1);
}
for(j=1;j<=k;j++)
{
printf("%d ",h[j]);
}
printf("\n");
}
}
#include<bits/stdc++.h>
using namespace std;
int n,m,ma,mb,i,j,ii,jj,k,a[1111][1111],ax,ay,axx,ayy,hx[1111111],hy[1111111],hxx[1111111],hyy[1111111],kkk;
bool pc[12255872],pcc[12255872],pccc[12255872],pcccc[21788234];
long long q[1111][1111],h[1111111],qzh=0,has,hass,hasss,hassss;
long long ewqzh(int x,int y,int xx,int yy)
{
return (q[xx][yy]-q[xx][y-1]-q[x-1][yy]+q[x-1][y-1]);
}
void up()
{
int kkg=kkk;
while(kkg>1&&h[kkg]<h[kkg/2])
{
h[0]=h[kkg];
h[kkg]=h[kkg/2];
h[kkg/2]=h[0];
hx[0]=hx[kkg];
hx[kkg]=hx[kkg/2];
hx[kkg/2]=hx[0];
hy[0]=hy[kkg];
hy[kkg]=hy[kkg/2];
hy[kkg/2]=hy[0];
hxx[0]=hxx[kkg];
hxx[kkg]=hxx[kkg/2];
hxx[kkg/2]=hxx[0];
hyy[0]=hyy[kkg];
hyy[kkg]=hyy[kkg/2];
hyy[kkg/2]=hyy[0];
kkg/=2;
}
}
void down()
{
int kkgx=1,kkgy=2;
while(((kkgy)<=kkk&&h[kkgy]<h[kkgx])||((kkgy+1)<=kkk&&h[kkgy+1]<h[kkgx]))
{
if(kkgy+1<=kkk&&h[kkgy]>h[kkgy+1])
{
kkgy++;
}
h[0]=h[kkgx];
h[kkgx]=h[kkgy];
h[kkgy]=h[0];
hx[0]=hx[kkgx];
hx[kkgx]=hx[kkgy];
hx[kkgy]=hx[0];
hy[0]=hy[kkgx];
hy[kkgx]=hy[kkgy];
hy[kkgy]=hy[0];
hxx[0]=hxx[kkgx];
hxx[kkgx]=hxx[kkgy];
hxx[kkgy]=hxx[0];
hyy[0]=hyy[kkgx];
hyy[kkgx]=hyy[kkgy];
hyy[kkgy]=hyy[0];
kkgx=kkgy;
kkgy*=2;
}
}
void add(long long xxx,int x,int y,int xx,int yy)
{
kkk++;
h[kkk]=xxx;
hx[kkk]=x;
hy[kkk]=y;
hxx[kkk]=xx;
hyy[kkk]=yy;
up();
}
void pop(int xxx)
{
h[0]=h[xxx];
h[xxx]=h[kkk];
h[kkk]=h[0];
hx[0]=hx[xxx];
hx[xxx]=hx[kkk];
hx[kkk]=hx[0];
hy[0]=hy[xxx];
hy[xxx]=hy[kkk];
hy[kkk]=hy[0];
hxx[0]=hxx[xxx];
hxx[xxx]=hxx[kkk];
hxx[kkk]=hxx[0];
hyy[0]=hyy[xxx];
hyy[xxx]=hyy[kkk];
hyy[kkk]=hyy[0];
kkk--;
down();
}
int main()
{
scanf("%d%d%d%d%d",&n,&m,&ma,&mb,&k);
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
scanf("%d",&a[i][j]);
}
}
q[1][1]=a[1][1];
for(i=2;i<=m;i++)
{
q[1][i]=(q[1][i-1]+a[1][i]);
}
for(i=2;i<=n;i++)
{
q[i][1]=(q[i-1][1]+a[i][1]);
}
for(i=2;i<=n;i++)
{
for(j=2;j<=m;j++)
{
q[i][j]=(a[i][j]+q[i-1][j]+q[i][j-1]-q[i-1][j-1]);
}
}
for(i=1;i<=(n-ma+1);i++)
{
for(j=1;j<=(m-mb+1);j++)
{
ax=i,ay=j,axx=i+ma-1,ayy=j+mb-1;
qzh=ewqzh(ax,ay,axx,ayy);
has=(qzh*11+ax*291143%12255871+ay*38833%12255871+axx*999983%12255871+ayy*122777%12255871)%12255871;
pc[has]=1;
hass=(qzh*13+ax*38833%12255871+ay*291143%12255871+axx*122777%12255871+ayy*999983%12255871)%12255871;
pcc[has]=1;
hasss=(qzh*13+ax*83%91815541+ay*89%91815541+axx*97%91815541+ayy*29%91815541)%91815541;
pccc[hasss]=1;
hasss=(qzh*2179+ax*29123%21788233+ay*113%21788233+axx*97%21788233+ayy*61%21788233)%21788233;
pcccc[hassss]=1;
add(qzh,ax,ay,axx,ayy);
}
}
for(i=1;i<=k-1;i++)
{
ax=hx[1]-1,ay=hy[1],axx=hxx[1],ayy=hyy[1];
if(ax>=1)
{
qzh=ewqzh(ax,ay,axx,ayy);
has=(qzh*11+ax*291143%12255871+ay*38833%12255871+axx*999983%12255871+ayy*122777%12255871)%12255871;
hass=(qzh*13+ax*38833%12255871+ay*291143%12255871+axx*122777%12255871+ayy*999983%12255871)%12255871;
hasss=(qzh*13+ax*83%91815541+ay*89%91815541+axx*97%91815541+ayy*29%91815541)%91815541;
hassss=(qzh*2179+ax*29123%21788233+ay*113%21788233+axx*97%21788233+ayy*61%21788233)%21788233;
if(pc[has]!=1||pcc[hass]!=1||pccc[hasss]!=1||pcccc[hassss]!=1)
{
pc[has]=1;
pcc[hass]=1;
pccc[hasss]=1;
pcccc[hassss]=1;
add(qzh,ax,ay,axx,ayy);
}
}
ax=hx[1],ay=hy[1]-1,axx=hxx[1],ayy=hyy[1];
if(ay>=1)
{
qzh=ewqzh(ax,ay,axx,ayy);
has=(qzh*11+ax*291143%12255871+ay*38833%12255871+axx*999983%12255871+ayy*122777%12255871)%12255871;
hass=(qzh*13+ax*38833%12255871+ay*291143%12255871+axx*122777%12255871+ayy*999983%12255871)%12255871;
hasss=(qzh*13+ax*83%91815541+ay*89%91815541+axx*97%91815541+ayy*29%91815541)%91815541;
hassss=(qzh*2179+ax*29123%21788233+ay*113%21788233+axx*97%21788233+ayy*61%21788233)%21788233;
if(pc[has]!=1||pcc[hass]!=1||pccc[hasss]!=1||pcccc[hassss]!=1)
{
pc[has]=1;
pcc[hass]=1;
pccc[hasss]=1;
pcccc[hassss]=1;
add(qzh,ax,ay,axx,ayy);
}
}
ax=hx[1],ay=hy[1],axx=hxx[1]+1,ayy=hyy[1];
if(axx<=n)
{
qzh=ewqzh(ax,ay,axx,ayy);
has=(qzh*11+ax*291143%12255871+ay*38833%12255871+axx*999983%12255871+ayy*122777%12255871)%12255871;
hass=(qzh*13+ax*38833%12255871+ay*291143%12255871+axx*122777%12255871+ayy*999983%12255871)%12255871;
hasss=(qzh*13+ax*83%91815541+ay*89%91815541+axx*97%91815541+ayy*29%91815541)%91815541;
hassss=(qzh*2179+ax*29123%21788233+ay*113%21788233+axx*97%21788233+ayy*61%21788233)%21788233;
if(pc[has]!=1||pcc[hass]!=1||pccc[hasss]!=1||pcccc[hassss]!=1)
{
pc[has]=1;
pcc[hass]=1;
pccc[hasss]=1;
pcccc[hassss]=1;
add(qzh,ax,ay,axx,ayy);
}
}
ax=hx[1],ay=hy[1],axx=hxx[1],ayy=hyy[1]+1;
if(ayy<=m)
{
qzh=ewqzh(ax,ay,axx,ayy);
has=(qzh*11+ax*291143%12255871+ay*38833%12255871+axx*999983%12255871+ayy*122777%12255871)%12255871;
hass=(qzh*13+ax*38833%12255871+ay*291143%12255871+axx*122777%12255871+ayy*999983%12255871)%12255871;
hasss=(qzh*13+ax*83%91815541+ay*89%91815541+axx*97%91815541+ayy*29%91815541)%91815541;
hassss=(qzh*2179+ax*29123%21788233+ay*113%21788233+axx*97%21788233+ayy*61%21788233)%21788233;
if(pc[has]!=1||pcc[hass]!=1||pccc[hasss]!=1||pcccc[hassss]!=1)
{
pc[has]=1;
pcc[hass]=1;
pccc[hasss]=1;
pcccc[hassss]=1;
add(qzh,ax,ay,axx,ayy);
}
}
pop(1);
}
printf("%d\n",h[1]);
}
4hash爆70,以后有时间找一个更好的判重方法!
休息一下吧,去看耶稣好不好?