BZOJ 1127

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define M 2020
using namespace std;
int n,k,a[M][M];
long long sum[M][M];
long long Get_Sum(int x1,int y1,int x2,int y2)
{
return sum[x2][y2]-sum[x1-][y2]-sum[x2][y1-]+sum[x1-][y1-];
}
void Output(int x1,int y1,int x2,int y2)
{
while( Get_Sum(x1,y1,x2,y2)>k* )
{
if(x1==x2)
y2--;
else
{
if( Get_Sum(x1+,y1,x2,y2)>=k )
x1++;
else
x2--;
}
}
printf("%d %d %d %d\n",y1,x1,y2,x2);
exit();
}
void Monotonous_Stack(int base,int h[])
{
static int stack[M],top;
static int l[M],r[M];
int i; for(top=,i=;i<=n+;i++)
{
while( top && h[stack[top]]>h[i] )
r[stack[top--]]=i-;
stack[++top]=i;
}
for(top=,i=n;i>=;i--)
{
while( top && h[stack[top]]>h[i] )
l[stack[top--]]=i+;
stack[++top]=i;
}
for(i=;i<=n;i++)
if(h[i])
{
long long temp=Get_Sum(base-h[i]+,l[i],base,r[i]);
if( temp>=k )
Output(base-h[i]+,l[i],base,r[i]);
}
}
int main()
{
int i,j;
cin>>k>>n;
for(i=;i<=n;i++)
for(j=;j<=n;j++)
{
scanf("%d",&a[i][j]);
if( a[i][j]>=k && a[i][j]<=k* )
{
printf("%d %d %d %d\n",j,i,j,i);
return ;
}
sum[i][j]=sum[i-][j]+sum[i][j-]-sum[i-][j-]+a[i][j];
}
static int h[M];
for(i=;i<=n;i++)
{
for(j=;j<=n;j++)
h[j]=a[i][j]>k*?:h[j]+;
Monotonous_Stack(i,h);
}
puts("NIE");
return ;
}

BZOJ 1127

NOIP 考前 队列复习的更多相关文章

  1. NOIP 考前 数论复习

    POJ 2891 x=r1 (mod a1) x=r2 (mod a2) x=a1*x+r1,x=a2*y+r2; a1*x-a2*y=r2-r1; 用Extend_Gcd求出m1*x+m2*y=d; ...

  2. NOIP 考前 数据结构复习

    BZOJ 1455 左偏树即可 #include <cstdio> #define LL long long ; struct Info{LL l,r,v,Dis;}Tree[Maxn]; ...

  3. NOIP 考前DP 复习

    POJ 2533 最长不降子序列 #include <cstdio> ; int a[Maxn],Pos[Maxn],F[Maxn],n,Ans; inline int Max(int x ...

  4. NOIP 考前 Tarjan复习

    POJ 1236 给定一个有向图,求: 1) 至少要选几个顶点,才能做到从这些顶点出发,可以到达全部顶点 2) 至少要加多少条边,才能使得从任何一个顶点出发,都能到达全部顶点 第一个就是缩点之后有多少 ...

  5. noip考前模板复习

    网络流 Dinic(搭配飞行员) //Serene #include<algorithm> #include<iostream> #include<cstring> ...

  6. Noip前的大抱佛脚----Noip真题复习

    Noip前的大抱佛脚----Noip真题复习 Tags: Noip前的大抱佛脚 Noip2010 题目不难,但是三个半小时的话要写四道题还是需要码力,不过按照现在的实力应该不出意外可以AK的. 机器翻 ...

  7. NOIP考前划水

    NOIP考前划水 君指先跃动の光は.私の一生不変の信仰に.唯私の超電磁砲永世生き! 要开始背配置了? 3行不谢. (setq c-default-style "awk") (glo ...

  8. NOIP 考前 并查集复习

    POJ 1182 把一个点拆成x,x+n,x+2*n,x吃y可以表示认为x,y+n是一类的,x+n,y+2*n是一类,x+2*n,y是一类. #include <cstdio> ; ],n ...

  9. NOIP考前复习-数制转换,数论模板与文件读写

    数制转换有两种题型,一般一题,分值1.5分. 题型一:R进制转十进制 解法就是:按权展开,但要注意各个位的权,最低位(最右边)的权是0次方,权值为1. 纯整数的情况: (11010110)2 = 1× ...

随机推荐

  1. DataFormatString 转

    数据绑定之DataFormatString 设定BoundField的DataFormatString,通常有以下几种 DataFormatString= "{0:C}" 货币,货 ...

  2. 使用C++11的一点总结

          C++11已不是新鲜技术,但对于我来说,工作中用得还不够多(前东家长时间使用gcc3.4.5,虽然去年升了4.8.2,但旧模块维护还是3.4.5居多:新东家用的是4.4.6,不能完整支持C ...

  3. app上传到App Store的快捷方法及步骤

    跳过证书的申请及配置概要文件的设置, 现在根据已有的配置概要文件及发布证书开始: 1.先在Xcode上的PROJECT和TARGETS->Build Setting->Code Signi ...

  4. 【Python⑤】python序列---list和tuple

    sequence 序列 sequence(序列)是一组有顺序的对象的集合.序列可以包含一个或多个元素,也可以没有任何元素. 我们之前所说的基本数据类型,都可以作为序列的对象.对象还可以是另一个序列.序 ...

  5. C++ 之引用

    int argc ,char * argv[] - argument count & argument vector argc - 命令行参数个数,argv[]依次指向每一个命令行参数,其中a ...

  6. 关于springMVC3.0基于注解方式的项目搭建

    前言:开发了几个月的AS3项目,感觉JAVA都用不太熟练了.刚好这几个抽的空,就把自己以前用过的Spring框架再搭一边, 并完整的记录下来 开发环境:tomcat + mysql+ java 1.所 ...

  7. javadoc 生成自定义的标签

    转自:http://www.blogjava.net/lishunli/archive/2010/01/12/309218.html Technorati 标记: tools 关键词 个性化地生成Ja ...

  8. Ftrl in tensorflow

    reference :点击这里https://github.com/tensorflow/tensorflow/issues/3725 讲解 http://www.tuicool.com/articl ...

  9. 高斯过程(gaussian process)

    Definition 1. A Gaussian Process is a collection of random variables, any finite number of which hav ...

  10. PowerMockito 同时mock多个对象

    有时候,需要测试的方法内有collections结构,就需要同时mock多个对象 被测方法: public class EmployeeService { public List<Integer ...