看了一眼这题所用的操作,我觉得二维树状数组珂做,然后发现如果按时间顺序把节点一个个加进去再判会TLE,但发现二分时间明显比刚刚的做法快,于是二分时间+暴力插入该时间之内的点+树状数组维护即可AC

贴个代码:

#include <cstdio>
#include <cstring>
#define ll long long
#define lowbit(x) (x&(-x)) inline ll read(){
ll x = 0; int zf = 1; char ch = ' ';
while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
if (ch == '-') zf = -1, ch = getchar();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;
} int C[1005][1005];
int n, m, k, q;
int xi[250005], yi[250005];
ll ti[250005]; void clr(){
memset(C, 0, sizeof(C));
} void modify(int i, int j, int val){
for(int x = i; x <= n; x += lowbit(x))
for(int y = j; y <= m; y += lowbit(y))
C[x][y] += val;
} int getsum(int i, int j){
int res = 0;
for(int x = i; x > 0; x -= lowbit(x))
for(int y = j; y > 0; y -= lowbit(y))
res += C[x][y];
return res;
} inline bool judge(ll num){
clr();
for (int i = 1; i <= q; ++i)
if (ti[i] <= num)
modify(xi[i], yi[i], 1);
for (int i = k; i <= n; ++i)
for (int j = k; j <= m; ++j){
int tmp1 = getsum(i, j) - getsum(i - k, j) - getsum(i, j - k) + getsum(i - k, j - k);
if (tmp1 == k * k)
return true;
}
return false;
} int main(){
n = read(), m = read(), k = read(), q = read();
ll _max = 0;
for (int i = 1; i <= q; ++i){
xi[i] = read(), yi[i] = read(), ti[i] = read();
if (ti[i] > _max) _max = ti[i];
}
ll l = 0, r = _max + 1, ans = -1;
while (l <= r){
ll mid = (l + r) >> 1ll;
if (judge(mid)){
r = mid - 1;
ans = mid;
}
else
l = mid + 1;
}
printf("%d", ans);
return 0;
}

[CF846D]Monitor题解的更多相关文章

  1. HDU3686 Traffic Real Time Query System 题解

    题目 City C is really a nightmare of all drivers for its traffic jams. To solve the traffic problem, t ...

  2. C#各种同步方法 lock, Monitor,Mutex, Semaphore, Interlocked, ReaderWriterLock,AutoResetEvent, ManualResetEvent

    看下组织结构: System.Object System.MarshalByRefObject System.Threading.WaitHandle System.Threading.Mutex S ...

  3. API Monitor简介(API监控工具)

    API Monitor是一个免费软件,可以让你监视和控制应用程序和服务,取得了API调用. 它是一个强大的工具,看到的应用程序和服务是如何工作的,或跟踪,你在自己的应用程序的问题. 64位支持 API ...

  4. 创建 Monitor 并测试 - 每天5分钟玩转 OpenStack(124)

    前面我们创建了 Pool,VIP 并添加了 Member.今天将创建 Monitor,然后测试 LBaaS 是否能够正常工作. 创建 Monitor LBaaS 可以创建 monitor,用于监控 P ...

  5. 11g新特性:Health Monitor Checks

    一.什么是Health Monitor ChecksHealth Monitor Checks能够发现文件损坏,物理.逻辑块损坏,undo.redo损坏,数据字典损坏等等.Health Monitor ...

  6. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  7. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

  8. BZOJ-2561-最小生成树 题解(最小割)

    2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lyd ...

  9. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

随机推荐

  1. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_07 缓冲流_1_缓冲流的原理

    一个字节一个字节的读取,先读取到a,a给到os操作系统.os再给JVM,.jVM再把a给java程序 读完a再读取b.这样一层层的返回,效率低下 一次读取,缓冲区数组返回来.

  2. iView 实战系列教程(21课时)_3.iView 实战教程之布局篇(一)

    Grid布局 先了解一下iview的24栅格布局 清理一下App.vue 然后从iview的color里面获取推荐的背景色 我们先渲染栅格 24列,然后再讲解他是一个什么东西: 栅格外面row包裹的, ...

  3. robot framework :List Variables-List变量及其用法

    [转自:https://blog.csdn.net/yezibang/article/details/52692342] 这一讲我们重点来介绍List Variables-List变量及其用法. 一. ...

  4. UI自动化之特殊处理四(获取元素属性\爬取页面源码\常用断言)

    获取元素属性\爬取页面源码\常用断言,最终目的都是为了验证我们实际结果是否等于预期结果 目录 1.获取元素属性 2.爬取页面源码 3.常用断言 1.获取元素属性 获取title:driver.titl ...

  5. 《好久不见》(Cover 陈奕迅)箫声远 洞箫

    Your browser does not support the audio element.

  6. clinical-逻辑核查数据的操作

    1. 前端页面样式 2. 前端代码 添加: 展示: 修改 删除 3. 后台代码 封装的DAO类数据 # coding: utf-8 from pdform.services.db.dbCore imp ...

  7. It's strange. I felt less lonely when I didnt know you.

    feasible:adj. 可行的 bypass: v. 绕开,避开 eclipse: n. 月食 raw: adj. 生的 foresee:v. 预见 premier:n. 总理 ,adj: 首要的 ...

  8. 时间同步,使用oracle自带的ctss

    crsctl check ctss  --observer mode cluvfy comp clocksync   -检查crss为啥没启用 根据不同版本删除ntp的配置和服务 AIX: stops ...

  9. the sum of two fixed value

    the sum of two fixed value description Input an array and an integer, fina a pair of number in the a ...

  10. Android Studio 于夜神模拟器进行连接

    本文使用夜神模拟器自带的nox_adb.exe在Android Studio中连接夜神模拟器. 1.在夜神模拟器的安装路径下,在bin文件夹下有个nox_adb.exe文件,复制黄色框路径如图: 2. ...