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. Balanced Binary Tree [LeetCode]

    Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary ...

  2. 前端常用的几个js判断(一)

    1. 禁止右键点击$(document).ready(function(){ $(document).bind("contextmenu",function(e){ return ...

  3. Fragment:关于Avoid non-default constructors in fragments的错误

    在android开发中,写了一个关于继承Fragment的类时,如果有重载构造函数时,会提示“Avoid non-default constructors in fragments: use a de ...

  4. django-pagination 分页栏长度控制

    在分页页数很多时,分页样式会很长影响美观 我们可以用两个方式控制: 1.找到django-pagination里的pagination\pagination.html,在<ul class=&q ...

  5. Linux内核分析课程总结

    Linux内核分析课程总结 By 20135203齐岳 知识梳理 (思维导图地址http://mindmap.4ye.me/mkxM0cFh/1) 从start _ kernel构造一个新的Linux ...

  6. 《Linux内核设计与实现》课本第五章学习笔记——20135203齐岳

    <Linux内核设计与实现>课本第五章学习笔记 By20135203齐岳 与内核通信 用户空间进程和硬件设备之间通过系统调用来交互,其主要作用有三个. 为用户空间提供了硬件的抽象接口. 保 ...

  7. mysql 删除重复记录语句

    mysql 根据条件删除重复记录 只保留最小id的重复数据 DELETEFROM newsWHERE news_id IN ( SELECT a.news_id FROM ( SELECT news_ ...

  8. Sql 获取向上取整、向下取整、四舍五入取整的实例

    [四舍五入取整截取] select round(54.56,0) [向下取整截取] SELECT FLOOR(54.56) [向上取整截取]  SELECT   CEILING(13.15) --MS ...

  9. iOS开发_内存泄漏、内存溢出和野指针之间的区别

    今天,在工作群中,被问到了内存泄漏和野指针指向的区别,自己答的不是很好,特意回来查了资料,在博文中总结一下经验,欢迎指正. 内存泄漏:是指在堆区,alloc 或new 创建了一个对象,但是并没有放到自 ...

  10. Eclipse 显示所有文件

    Package Explorer -> View Menu -> Filters -> uncheck .* resources http://stackoverflow.com/q ...