USACO 12月 2020-2021 December Contest Silver银组 题解

P7148 [USACO20DEC] Cowntagion S 题目描述 Farmer John 和他的农民团队为了控制牛传染病 COWVID-19 在他们农场间的传播而夜以继日地工作。 他们共同监控着 NNN 个农场(1≤N≤1051≤N≤10^51≤N≤105),编号为 1…N1…N1…N。农场间由 N−1N−1N−1 条道路连接,使得每个农场都可以从农场 111 出发经过一些道路到达。 很不幸,农场 111 中的一头奶牛的 COWVID-19 检测呈阳性。暂时这个农场的其他奶牛以及其他农场的所有奶牛都还没有染上疾病。然而,根据这个疾病通过接触传播的特性,Farme 阅读详情

Problem 1. Cowntagion

Farmer John and his fellow farmers have been working nonstop to control the spread of the terrible bovine disease COWVID-19 across their farms.

Together, they oversee a collection of NN farms (1≤N≤1051≤N≤105), conveniently numbered 1…N1…N. The farms are connected by a set of N−1N−1 roads such that any farm can be reached from farm 1 by some sequence of roads.

Unfortunately, a cow in farm 1 has just tested positive for COWVID-19. None of the other cows at that farm or at any other farms have the disease yet. However, knowing the contagious nature of the disease, Farmer John anticipates exactly one of the following adverse events on each successive day:

(1) In a single farm, a "superspreader" event causes the number of cows at that farm with COWVID-19 to double; or

(2) A single cow with COWVID-19 moves along a road from one farm to an adjacent farm.

Farmer John is worried about how fast the outbreak might spread. Please help him by determining the minimum possible number of days before it could be the case that at least one cow in every farm has the disease.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line contains the single integer NN. The next N−1N−1 lines each contain two space-separated integers aa and bb describing a road between farms aa and bb. Both aa and bb are in the range 1…N1…N.

OUTPUT FORMAT (print output to the terminal / stdout):

The minimum number of days until the outbreak could reach every farm.

SAMPLE INPUT:

4
1 2
1 3
1 4

SAMPLE OUTPUT:

5

One possible sequence of events corresponding to this example is the following: the number of sick cows in farm 1 doubles and then doubles again, so that after two days, there are 4 sick cows in farm 1. In each of the next 3 days, a sick cow travels from farm 1 to each of farms 2, 3, and 4 respectively. After 5 days, at least 1 sick cow exists at each farm.

SCORING:

  • In test cases 1-4, every farm is connected directly to farm 1 (aside from farm 11 itself).
  • In test cases 5-7, farms 2…N2…N are each adjacent to at most two roads.
  • In test cases 8-15, there are no additional constraints.

Problem 2. Rectangular Pasture

Farmer John's largest pasture can be regarded as a large 2D grid of square "cells" (picture a huge chess board). Currently, there are NN cows occupying some of these cells (1≤N≤25001≤N≤2500).

Farmer John wants to build a fence that will enclose a rectangular region of cells; the rectangle must be oriented so its sides are parallel with the xx and yy axes, and it could be as small as a single cell. Please help him count the number of distinct subsets of cows that he can enclose in such a region. Note that the empty subset should be counted as one of these.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line contains a single integer NN. Each of the next NN lines Each of the next NN lines contains two space-separated integers, indicating the (x,y)(x,y) coordinates of a cow's cell. All xx coordinates are distinct from each-other, and all yy coordinates are distinct from each-other. All xx and yy values lie in the range 0…1090…109.

OUTPUT FORMAT (print output to the terminal / stdout):

The number of subsets of cows that FJ can fence off. It can be shown that this quantity fits within a signed 64-bit integer (e.g., a "long long" in C/C++).

SAMPLE INPUT:

4
0 2
1 0
2 3
3 5

SAMPLE OUTPUT:

13

There are 2424 subsets in total. FJ cannot create a fence enclosing only cows 1, 2, and 4, or only cows 2 and 4, or only cows 1 and 4, so the answer is 24−3=16−3=1324−3=16−3=13.

SCORING:

  • Test cases 2-3 satisfy N≤20N≤20.
  • Test cases 4-6 satisfy N≤100N≤100.
  • Test cases 7-12 satisfy N≤500N≤500.
  • Test cases 13-20 satisfy no additional constraints.

Problem 3. Stuck in a Rut

Farmer John has recently expanded the size of his farm, so from the perspective of his cows it is effectively now infinite in size! The cows think of the grazing area of the farm as an infinite 2D grid of square "cells", each filled with delicious grass (think of each cell as a square in an infinite chessboard). Each of Farmer John's NN cows (1≤N≤10001≤N≤1000) starts out in a different cell; some start facing north, and some start facing east.

Every hour, every cow either

  • Stops (and then remains stopped from that point on) if the grass in her current cell was already eaten by another cow.
  • Eats all the grass in her current cell and moves one cell forward according to the direction she faces.

Over time, each cow therefore leaves a barren "rut" of empty cells behind her.

If two cows move onto the same grassy cell in the same move, they share the cell and continue moving in their respective directions in the next hour.

Farmer John isn't happy when he sees cows that stop grazing, and he wants to know who to blame for his stopped cows. If cow bb stops in a cell that cow aa originally ate, then we say that cow aa stopped cow bb. Moreover, if cow aa stopped cow bb and cow bb stopped cow cc, we say that cow aa also stopped cow cc (that is, the "stopping" relationship is transitive). Each cow is blamed in accordance with the number of cows she stopped. Please compute the amount of blame assigned to each cow -- that is, the number of cows she stopped.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line of input contains NN. Each of the next NN lines describes the starting location of a cow, in terms of a character that is either N (for north-facing) or E (for east-facing) and two nonnegative integers xx and yy (0≤x≤1090≤x≤109, 0≤y≤1090≤y≤109) giving the coordinates of a cell. All xx-coordinates are distinct from each-other, and similarly for the yy-coordinates.

To be as clear as possible regarding directions and coordinates, if a cow is in cell (x,y)(x,y) and moves north, she ends up in cell (x,y+1)(x,y+1). If she instead had moved east, she would end up in cell (x+1,y)(x+1,y).

OUTPUT FORMAT (print output to the terminal / stdout):

Print NN lines of output. Line ii in the output should describe the blame assigned to the iith cow in the input.

SAMPLE INPUT:

6
E 3 5
N 5 3
E 4 6
E 10 4
N 11 1
E 9 2

SAMPLE OUTPUT:

0
0
1
2
1
0

In this example, cow 3 stops cow 2, cow 4 stops cow 5, and cow 5 stops cow 6. By transitivity, cow 4 also stops cow 6.

SCORING:

  • In test cases 2-5, all coordinates are at most 20002000.
  • In test cases 6-10, there are no additional constraints.

基于TL431与光耦的电压反馈环路优化设计实战 本文深入探讨了基于TL431与光耦的电压反馈环路优化设计实战。文章从理解这对“黄金搭档”的工作原理入手,详细拆解了电压采样电阻网络、偏置电路、光耦工作点设置以及动态补偿网络的设计心法与计算步骤。重点分享了如何通过RC补偿网络调试,确保环路在各种负载下稳定可靠,并提供了关键的实战避坑指南,帮助工程师解决电源设计中常见的振荡、噪声及可靠性问题。 阅读详情

相关推荐

PID调参避坑手册:用APM/PX4飞控让无人机稳如老狗

本文提供了一份针对APM/PX4飞控的PID调参实战指南。文章从理解PID控制原理出发,详细解析了级联控制结构,并给出了从内环到外环的五步调参流程与数据日志分析方法,帮助无人机爱好者避开常见误区,实现稳定飞行。

red88的博客 878

USACO2020DEC第四题(Cowntagion)题解

题目 题目描述 Farmer John 和他的农民团队为了控制牛传染病 COWVID-19 在他们农场间的传播而夜以继日地工作。 他们共同监控着 NN 个农场(1≤N≤10^5 ),编号为 1…N。农场间由 N−1条道路连接,使得每个农场都可以从农场 1出发经过一些道路到达。 很不幸,农场 1中的一头奶牛的 COWVID-19 检测呈阳性。暂时这个农场的其他奶牛以及其他农场的所有奶牛都还没有染上疾病。然而,根据这个疾病通过接触传播的特性,Farmer John 推测每一天都会有以下不利的事件之一发生: (1

风斯在下 1613

QGIS-空间分析-核密度分析

本文在QGIS软件中使用核密度估计法分析全球历年的地震数据,旨在分析出地震频发且严重的区域,为地震防控提供参考依据。全球历年地震数据来源于网络,仅用于技术学习探索。通过核密度分析,可以观察到南美、美国西部海岸线和太平洋北部区域在全球地震分布状态中是最为集中和强烈的。

imxiezy的博客 2471

USACO2020DEC第五题(Rectangular Pasture)题解

题目 题目描述 Farmer John 最大的牧草地可以被看作是一个由方格组成的巨大的二维方阵(想象一个巨大的棋盘)。现在,有 N 头奶牛正占据某些方格(1≤N≤2500)。 Farmer John 想要建造一个可以包围一块矩形区域的栅栏;这个矩形必须四边与 x 轴和 y 轴平行,最少包含一个方格。请帮助他求出他可以包围在这样的区域内的不同的奶牛子集的数量。注意空集应当被计算为答案之一。 输入格式 输入的第一行包含一个整数 N。以下 N 行每行包含两个空格分隔的整数,表示一头奶牛所在方格的坐标 (x,y)。

风斯在下 2090

Camera 基础知识

Raw Sensor输出的Data格式为Raw,图像的效果处理使用BB端的ISP,BB端接收Raw data后进行一系列的图像处理(OB,Shading,AWB,Gamma,EE,ANR等),效果方面由BB端控制,需要针对不同的模组进行效果调试,Raw sensor是目前的主流,数据量比YUV Sensor小(RAW10 格式的sensor 1个pixel 10个bit)使用平台ISP处理,能支持较大的size。不过,相位对焦并不是那么完美,它对光线的要求就比较高,在弱光拍摄环境下,相位对焦就无能威力了。

手机-手表蓝牙开发工程师的博客 3071

星空组网 vs 蒲公英 vs Tailscale:2024年国内免费异地组网工具横评(含实测数据)

本文对2024年国内主流免费异地组网工具星空组网、蒲公英和Tailscale进行了深度横向评测。基于实测数据,重点分析了三者在P2P成功率、中继延迟、传输速度及稳定性方面的表现,为中小企业、远程办公及个人开发者提供了清晰的选择指南。星空组网在国内网络环境下展现出优秀的平衡性。

weixin_29217235的博客 1478

【题解】USACO 2020 OPEN Sliver(银组)

Social Distancing 题面 题目描述 由于高传染性的牛传染病 COWVID-19 的爆发,Farmer John 非常担忧他的奶牛们的健康。 为了限制疾病的传播,Farmer John 的 N 头奶牛(2≤N≤105)(2≤N≤10^5)(2≤N≤105)决定践行“社交距离”,分散到农场的各处。农场的形状如一维数轴,上有 M 个互不相交的区间(1≤M≤105)(1≤M≤10^5)(1...

_BOSS_的博客 3026

RK3588部署rtmpose模型

摘要: 本文详细介绍了在RK3588开发板上部署RTMPose模型的全流程。首先在Ubuntu环境中搭建MMCV框架,通过MMPose工具将PTH模型转换为ONNX格式。随后使用RKNN-Toolkit2将ONNX模型转换为RKNN格式,并完成开发板部署。关键步骤包括模型转换(PTH→ONNX→RKNN)、环境配置和推理验证,最终实现人体姿态估计功能。整个过程涉及MMPose、RKNN-Toolkit等工具链的使用,为边缘计算场景下的实时姿态分析提供了可行方案。

qq_44224801的博客 1223

AcWing每日一题 社交距离

每日一题

ACMtourist的博客 828

安卓开发者必看:Win11最新Fastboot驱动安装避坑指南(含Android Bootloader Interface选择技巧)

本文为安卓开发者提供了Windows 11系统下Fastboot驱动安装的详细指南,特别针对Android Bootloader Interface选择技巧和多设备并发连接时的驱动冲突问题。通过解析Windows 11的特殊驱动验证机制,推荐使用Google官方USB驱动,并提供安装流程、版本选择建议及疑难问题排查方法,帮助开发者高效完成开发环境配置。

sea99的博客 1351

ISP Tuning实战指南:从基础到高级的色彩与亮度优化

本文详细介绍了ISP Tuning的基础概念与高级调优技术,包括黑电平校正(BLC)、自动白平衡(AWB)、色彩校正矩阵(CCM)和Gamma曲线调整等核心算法。通过实战案例和调试技巧,帮助工程师提升摄像头成像质量,解决高光过曝、暗部噪点等常见问题,适用于智能门铃、车载摄像头等多种场景。

weixin_30879169的博客 112

【USACO 2017 December Silver】Milk Measurement题解

Description 最初,农夫约翰的每头奶牛每天生产G加仑的牛奶(1≤G≤10^9)。由于随着时间的推移,奶牛的产奶量可能会发生变化,农夫约翰决定定期对奶牛的产奶量进行测量,并将其记录在日志中。 他的日志中的记录如下: 35 1234 -2 14 2345 +3 第一个条目表明:在第35天,1234号奶牛的产奶量比上次测量时降低了2加仑。 第二个条目表明:在第14天,2345号奶牛的产奶量比上次测量时增加了3加仑。 农夫约翰只有在任何一天内做最多一次测量的时间(即每天最多做一次测量,但可能不做)。不幸的

MZHjr的博客 1149

PCL 加权局部最优投影(WLOP)简化算法

WLOP算法是一种点云重采样方法,通过迭代优化实现点云均匀化和特征保留。算法包含数据项(加权平均位置保持几何特征)和正则化项(排斥邻近点实现均匀分布)两部分。代码实现基于PCL库,通过KD树加速邻域搜索,使用高斯权重函数计算点位置更新。参数包括输出点比例、邻域半径、正则化权重和迭代次数。该算法不依赖网格信息,适合处理大规模扫描数据的预处理优化。

点云侠的博客 647

USACO 12月 2021-2022 December Contest Silver 题解

USACO 2021 DEC Silver 真题题解

EN- 1134

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

USACO 2024 December Contest, SilverProblem 1. Cake Game (AcWing 6118. 蛋糕游戏)Python 题解

Bessie 和 Elsie 发现了一行N个蛋糕2≤N≤5⋅105N为偶数),大小依次为a1​a2​aN​1≤ai​≤109。两头奶牛都想吃到尽可能多的蛋糕。但是,作为非常文明的奶牛,她们决定玩一个游戏来分割蛋糕!游戏在两头奶牛之间轮流进行回合。每个回合进行以下两者之一:Bessie 选择两个相邻的蛋糕并将它们堆叠起来,制造大小为两者大小之和的一个新蛋糕。Elsie 选择最左边或最右边的蛋糕藏起来。

weixin_52740785的博客 926

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

USACO 2011 December Contest题解

  USACO 2011 December Contest Silver Division Problem 1. CowPhotography 首先我们可以发现:若在大于等于3张照片中a牛都在b牛的前面,那么在初始状态中a牛就在b牛前面。 于是我们可以记下每张照片中每头牛的位置,然后在sort中加一个神奇的cmp函数(若a牛在2张以上的照片中在b牛前,返回1,否则返回0) 代码如下: ...

Monster的博客 878

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

USACO 2019 December Contest, Silver 题解

1.MooBuzz Description Farmer John 的奶牛们最近成为了一个简单的数字游戏“FizzBuzz”的狂热玩家。这个游戏的规则很简单:奶牛们站成一圈,依次从一开始报数,每头奶牛在轮到她的时候报一个数。如果一头奶牛将要报的数字是 3 的倍数,她应当报“Fizz”来代替这个数。如果一头奶牛将要报的数字是 5 的倍数,她应当报“Buzz”来代替这个数。如果一头奶牛将要报的数字是 ...

帅比王的博客 2430

USACO 2018 December Contest Silver 题解

T1 Convention 【题意】 有nnn头奶牛,第iii头在a[i]a[i]a[i]时刻到达,有mmm量大巴车接他们,每辆最多载kkk人(注意不需要坐满才能走),求等候时间最长的奶牛最短时间是多少 【分析】 又是最大值最小的问题,很容易想到二分答案 二分等候时间最长的奶牛等候midmidmid分钟 checkcheckcheck函数也很好想 先按到达时间把奶牛排序 记录第一个上车的时间和已上...

Hacheylight 749

USACO 2024年2月比赛 铜组题解

USACO 2024年2月比赛 铜组题解

超哥聊信奥 1666

USACO 2018 December Contest, Silver T1 Convention

#include<bits/stdc++.h> using namespace std; int n,m,c,t[100001]; bool cmp(int a,int b) { return a>b; } bool check(int lngst) { int ct=t[1],cn=1,cnt=1; for (int i=2;i<=n;++i) ...

满福大坑填平日,家祭无忘告乃翁 807

【USACO 2019 December Silver】MooBuzz

俗话说骗分过样例,暴力出奇迹,这句话在这道题上完美的印证了…… 先上个图 (这道题数据也太水了) n只有10^9,用二分完全不会爆,不信看这里~ 二分的效率非常高,适用于答案在一个固定范围内的题目,是所有算法里效率排名第二的,仅次于常数阶的算法 ps:算法效率从高到低分别为:O(1),O(log2n),O(               一条华丽的分割线 ————————————————————...

qq_42040511的博客 388

USACO 2017 December Contest

0题,很尴尬。 Bronze Division: 1. Blocked Billboard 题意:给你两个不相交的长方形,和第三个长方形障碍物。问你前面两个长方形的可见面积是多少。 观察:因为前两个长方形不相交,分别计算每个长方形和障碍物之间的关系就好了 方法:注意如何处理不相交的情况 1 #include <cstdio> 2 #include &lt...

weixin_30765505的博客 494

USACO翻译:USACO 2014 DEC Silver三题

USACO 2014 DEC SILVER 一、题目概览 中文题目名称 回程 马拉松 奶牛慢跑 英文题目名称 piggyback marathon cowjog 可执行文件名 piggyback marathon cowjog 输入...

weixin_34240657的博客 412

USACO 2016 January Contest, SilverProblem 2. Subsequences Summing to Sevens 题解

而前缀和。

2509_90426577的博客 339

JZOJ【USACO 2017 December Silver】Milk Measurement

Description Each of Farmer John's cows initially produces G gallons of milk per day (1≤G≤109). Since the milk output of a cow is known to potentially change over time, Farmer John decides to take p...

Old_Whig的博客 164

USACO 2007 December Contest, Silver Problem 2. Building Roads Kruskal最小生成树算法

PROBLEM: (ENGLISH VERSION) Farmer John had just acquired several new farms! He wants to connect the farms with roads so that he can travel from any farm to any other farm via a sequence of road...

dianyi2475的博客 250
上一篇: USACO 2月 2021-2022 February Contest Silver银组 题解
下一篇: AcWing第 81 场周赛
alicelee2735
博客等级 码龄7年 2539粉丝 75原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值