http://codeforces.com/contest/846/problem/D

二分答案

适合于:

判断在t时候第一次成立

哪个状态是最小代价

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define E 2.7182818284
const ll mod=1e9+;//
const int maxn=5e2+; struct node
{
int x,y,t;
}f[maxn*maxn]; int K,s,t,a[maxn][maxn],tot[maxn][maxn]={}; int cmp(node a,node b)
{
return a.t<b.t;
} bool judge()
{
int i,j;
for (i=K;i<=s;i++)
for (j=K;j<=t;j++)
if (tot[i][j]-tot[i-K][j]-tot[i][j-K]+tot[i-K][j-K]==K*K)
return ;
return ;
} int main()
{
int q,i,j,l,r,m;
scanf("%d%d%d%d",&s,&t,&K,&q);
for (i=;i<=q;i++)
scanf("%d%d%d",&f[i].x,&f[i].y,&f[i].t); sort(f+,f+q+,cmp); l=,r=q;
while (l<=r)
{
memset(a,,sizeof(a));
m=(l+r)>>; for (i=;i<=m;i++)
a[f[i].x][f[i].y]=;
for (i=;i<=s;i++)
for (j=;j<=t;j++)
tot[i][j]=tot[i-][j]+tot[i][j-]-tot[i-][j-]+a[i][j];
if (judge())
r=m-;
else
l=m+;
}
if (l==q+)
printf("-1");
else
printf("%d",f[l].t);
return ;
}
/*
2 2 2 4
1 2 1
1 1 4
2 2 3
2 1 2 2 2 1 4
1 2 1
1 1 4
2 2 3
2 1 2 2 2 2 0
*/

D. Monitor Educational Codeforces Round 28的更多相关文章

  1. Educational Codeforces Round 28

    A. Curriculum Vitae 题目链接:http://codeforces.com/contest/846/problem/A 题目意思:给你一个只包含0-1的数组,现在要求去可以去掉一些元 ...

  2. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

  3. [Educational Codeforces Round 16]D. Two Arithmetic Progressions

    [Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...

  4. [Educational Codeforces Round 16]C. Magic Odd Square

    [Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...

  5. [Educational Codeforces Round 16]B. Optimal Point on a Line

    [Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...

  6. [Educational Codeforces Round 16]A. King Moves

    [Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...

  7. Educational Codeforces Round 6 C. Pearls in a Row

    Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...

  8. Educational Codeforces Round 9

    Educational Codeforces Round 9 Longest Subsequence 题目描述:给出一个序列,从中抽出若干个数,使它们的公倍数小于等于\(m\),问最多能抽出多少个数, ...

  9. Educational Codeforces Round 37

    Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...

随机推荐

  1. nginx keepalived 高可用方案(转)

    转自: https://www.cnblogs.com/leeSmall/p/9356535.html 一.Nginx Rewrite 规则 1. Nginx rewrite规则 Rewrite规则含 ...

  2. “Hello World!”Final发布文案加美工

    文案: 大家好,我们是“Hello World!”团队,本次我将向大家简要介绍一下空天猎的final发布,在空天猎final发布中,我主要从以下两个方面向大家进行介绍,第一个方面是增加了敌方的boss ...

  3. Thunder——爱阅app(测评人:方铭)

    B.Thunder——爱阅app(测评人:方铭) 一.基于NABCD评论作品,及改进建议 每个小组评论其他小组Alpha发布的作品: 1.根据(不限于)NABCD评论作品的选题: 2.评论作品对选题的 ...

  4. mybatis oracle和mysql like模糊查询写法

    oracle:RESOURCE_NAME LIKE '%' || #{resourceName} || '%'mysql:RESOURCE_NAME like concat(concat(" ...

  5. Aspose.words Java基于模板生成word之纯文本内容

    一,创建word模板 1.新建一个word文档 2.分别给四个参数设置域 (1)将鼠标置于想要设置域的地方 (2)设置域名 (3)设置好之后如下图所示 二,项目 1,引入maven依赖 <dep ...

  6. 预备作业02 : 体会做中学(Learning By Doing)

    1.你有什么技能比大多人(超过班级90%以上)更好? 我认为我是一个比较爱摄影和绘画的人,虽然说说不上技术精湛,但还是能拿出手的. 2.针对这个技能的获取你有什么成功的经验? 接触摄影和绘画都是因为喜 ...

  7. java学习de路线建议

    我想谈一谈我的一些关于网页学习的小感悟吧.之所以是写这个的原因完全是想告诉现在还处在网页学习的初始阶段的同学一些我学习走过的弯路,但我说的也仅是我个人的理解,毕竟我只能是JavaWeb开发的新手,所以 ...

  8. 第二阶段Sprint冲刺会议7

    进展:试着把视频录制功能加到时间提醒中,但是整合没有成功,今天没有进展.

  9. 软工1816 · 作业(十二)Beta答辩总结

    组长博客 宣传视频 github团队项目仓库 本组成员 队员姓名与学号 124 王彬(组长) 206 赵畅 215 胡展瑞 320 李恒达 131 佘岳昕 431 王源 206 陈文垚 209 陈志炜 ...

  10. 结对随即四则运算(带界面Java版)

    //随机四则运算类 public class 随机四则运算 { public static void main(String[] args) { new 界面();//进入随机四则运算的首界面 } } ...