当前位置: 首页 > 网络知识

[BZOJ1604] [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居(好题)

时间:2026-01-29 09:38:34

传送门

良心题解

#include <set> #include <cstdio> #include <iostream> #include <algorithm> #define N 100001 #define LL long long #define INF (~(1 << 31)) using namespace std; int n, c, h = 1, ans, ans1; int f[N], sum[N]; struct node }p[N]; multiset <node> s; multiset <node> :: iterator it; inline bool operator < (const node &a, const node &b) inline int read() inline int find(int x) inline int merge(int x, int y) } int main() sort(p + 1, p + n + 1); s.insert(node(INF, 0)); s.insert(node(INF, 0)); for(i = 1; i <= n; i++) y = p[i].y; it = s.lower_bound(node(p[i].y, i)); node r = *it, l = *it; if(r.x y <= c) merge(r.y, i); if(y l.x <= c) merge(l.y, i); s.insert(node(p[i].y, i)); } for(i = 1; i <= n; i++) sum[find(i)]++; for(i = 1; i <= n; i++) ans1 = max(ans1, sum[i]); printf("%d %d\n", ans, ans1); return 0; }

  



上一篇:【模板】AC自动机
下一篇:[BZOJ1583] [Usaco2009 Mar]Moon Mooing 哞哞叫(队列)
stl 好题 并查集
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素