D. Monitor Educational Codeforces Round 28
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的更多相关文章
- Educational Codeforces Round 28
A. Curriculum Vitae 题目链接:http://codeforces.com/contest/846/problem/A 题目意思:给你一个只包含0-1的数组,现在要求去可以去掉一些元 ...
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- [Educational Codeforces Round 16]C. Magic Odd Square
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...
- [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 ...
- [Educational Codeforces Round 16]A. King Moves
[Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...
- Educational Codeforces Round 6 C. Pearls in a Row
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...
- Educational Codeforces Round 9
Educational Codeforces Round 9 Longest Subsequence 题目描述:给出一个序列,从中抽出若干个数,使它们的公倍数小于等于\(m\),问最多能抽出多少个数, ...
- Educational Codeforces Round 37
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...
随机推荐
- 笨办法学Python - 习题1: A Good First Program
在windows上安装完Python环境后,开始按照<笨办法学Python>书上介绍的章节进行练习. 习题 1: 第一个程序 第一天主要是介绍了Python中输出函数print的使用方法, ...
- [整理]CHttpConnection的使用
使用步骤: 1.构造一个CInternetSession的实例 CInternetSession* pSession =new CinternetSession(); //CInternetSessi ...
- 使用谷歌浏览器调试WEB前端的一些必备调试技巧
转载:http://www.techug.com/post/chrome-debug-tips.html Chrome的开发者工具是个很强大的东西,相信程序员们都不会陌生,不过有些小功能可能并不为大众 ...
- Python脚本文件(.py)打包为可执行文件(.exe)即避免命令行中包含Python解释器
在最近的软件工程作业中用到了将Python脚本转化为exe文件这一过程,网上各种博客介绍了很多,有些东西都不完全,我也是综合了很多种方法最后才实现的,我就把这些整理出来,希望可以帮到大家~ 一.环 ...
- 王者荣耀交流协会final发布第五次scrum例会
1.例会照片 成员高远博,冉华,王磊,王玉玲,任思佳,袁玥,王磊,王超. master:王磊 2.时间跨度 2017年12月5日 18:00 — 18:21,总计21分钟 3.地点 一食堂二楼沙发座椅 ...
- C++:构造函数3——浅拷贝和深拷贝
一.默认拷贝构造函数 拷贝构造函数是一种特殊的构造函数(详情见:http://www.cnblogs.com/duwenxing/p/7429777.html),如果用户在定义类时没有显式地编写拷贝构 ...
- Apache优化之多路处理模块理解
前言: 当项目被多人访问时导致访问数度变慢,查了许多资料,了解到Apache的核心模块——MPM(多路处理访问模块).在此对MPM的一些知识点进行整理. MPM_WINNT模块 windows系统使用 ...
- 作死实验,删除libc.so.6
参考https://www.cnblogs.com/fjping0606/p/4551475.html https://www.cnblogs.com/weijing24/p/5890031.html ...
- 字符串拆分函数 func_splitstr
create type str_split is table of varchar2(4000) ; 1 CREATE OR REPLACE FUNCTION splitstr(p_string IN ...
- [转帖]ssd固态硬盘的Trim命令是什么?
ssd固态硬盘的Trim命令是什么? 收藏 分享 邀请 许多用户朋友在购买SSD的时候都会特别强调Trim,不过Trim是什么?做什么用的? 什么是Trim? Trim指令也叫disable ...