BZOJ 水题5连发 (1602 && 1603 && 1599 && 1651 &&1646)

8 篇文章 0 订阅
4 篇文章 0 订阅

想不到BZOJ上也会有水题。。

懒得一篇一篇发了,代码也不贴了。。

1602: [Usaco2008 Oct]牧场行走

Time Limit: 5 Sec   Memory Limit: 64 MB
Submit: 1158   Solved: 594
[ Submit][ Status]

Description

N头牛(2<=n<=1000)别人被标记为1到n,在同样被标记1到n的n块土地上吃草,第i头牛在第i块牧场吃草。 这n块土地被n-1条边连接。 奶牛可以在边上行走,第i条边连接第Ai,Bi块牧场,第i条边的长度是Li(1<=Li<=10000)。 这些边被安排成任意两头奶牛都可以通过这些边到达的情况,所以说这是一棵树。 这些奶牛是非常喜欢交际的,经常会去互相访问,他们想让你去帮助他们计算Q(1<=q<=1000)对奶牛之间的距离。


裸树上倍增
就当复习模板了。。

1603: [Usaco2008 Oct]打谷机

Time Limit: 5 Sec   Memory Limit: 64 MB
Submit: 639   Solved: 485
[ Submit][ Status]

Description

Farmer John有一个过时的打谷机(收割小麦),它需要带子来带动。发动机驱动轮1总是顺时针旋转的,用来带动转轮2,转轮2来带动转轮3,等等。一共有n(2<=n<=1000)个转轮(n-1条带子)。上面的图解描述了转轮的两种连接方式,第一种方式使得两个轮子旋转的方向相同,第二种则相反。 给出一串带子的信息: *Si—驱动轮 *Di—被动轮 *Ci—连接的类型(0=直接连接,1=交叉连接) 不幸的是,列出的信息是随即的。 作为样例,考虑上面的图解,n=4,转轮1是驱动轮,可以得知最后转轮4是逆时针旋转的。


傻逼BFS即可。。

1599: [Usaco2008 Oct]笨重的石子

Time Limit: 10 Sec   Memory Limit: 162 MB
Submit: 781   Solved: 531
[ Submit][ Status]

Description

贝西喜欢棋盘游戏和角色扮演类游戏所以她说服Farmer John把她带到玩具店,在那里,她购买了三个不同的骰子,这三个质量均匀的骰子,分别有S1,S2,S3个面。(2 <= S1 <= 20; 2 <= S2 <= 20; 2 <= S3 <= 40). 贝西掷啊掷啊掷啊,想要知道出现几率最大的和是多少。 问题给出三个骰子的面数,让你求出出现几率最大的和是多少。如果有很多种和出现的几率相同,那么就输出小的那一个。

傻逼暴力。。。

1651: [Usaco2006 Feb]Stall Reservations 专用牛棚

Time Limit: 10 Sec   Memory Limit: 64 MB
Submit: 549   Solved: 303
[ Submit][ Status]

Description

Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time interval A..B (1 <= A <= B <= 1,000,000), which includes both times A and B. Obviously, FJ must create a reservation system to determine which stall each cow can be assigned for her milking time. Of course, no cow will share such a private moment with other cows. Help FJ by determining: * The minimum number of stalls required in the barn so that each cow can have her private milking period * An assignment of cows to these stalls over time

有N头牛,每头牛有个喝水时间,这段时间它将专用一个Stall 现在给出每头牛的喝水时间段,问至少要多少个Stall才能满足它们的要求


这道题有点技术含量。。
对于每一个线段,左端标+1,右端标-1,快排一遍(双关键字 先比坐标再比权值)
然后扫描线扫一遍,取其中最大值
Code:
const shuru='Stall.in';
	  shuchu='Stall.out';
	  maxn=100001;
var	v,a:array[0..maxn] of longint;
	x,tmp,y,tot,i,j,k,n,ans:longint;
procedure init;
begin	
	readln(n);
	for i:=1 to n do
	begin
		readln(x,y);
		a[2*i-1]:=x; v[2*i-1]:=1;
		a[2*i]:=y;   v[2*i]:=-1;
	end;
end;
procedure qsort(left,right:longint);
var i,j,mid,mid1:longint;
begin
	i:=left; j:=right; mid:=a[(i+j) shr 1]; mid1:=v[(i+j) shr 1];
	repeat
		while ((a[i]<mid) or ((a[i]=mid) and (v[i]>mid1))) do inc(i);
		while ((a[j]>mid) or ((a[j]=mid) and (v[j]<mid1))) do dec(j);
		if i<=j then begin
						tmp:=a[i]; a[i]:=a[j]; a[j]:=tmp;
						tmp:=v[i]; v[i]:=v[j]; v[j]:=tmp;
						inc(i); dec(j);
					 end;
	until i>j;
	if j>left  then qsort(left,j);
	if i<right then qsort(i,right);
end;
function max(a,b:longint):longint;
begin
	if a>b then exit(a);
	exit(b);
end;
procedure main;
begin
	init;
	qsort(1,2*n);
	for i:=1 to 2*n do
	begin
		tot:=tot+v[i];
		ans:=max(ans,tot);
	end;
	writeln(ans);
end;
begin
	main;
end.

1646: [Usaco2007 Open]Catch That Cow 抓住那只牛

Time Limit: 5 Sec   Memory Limit: 64 MB
Submit: 682   Solved: 327
[ Submit][ Status]

Description

Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 <= N <= 100,000) on a number line and the cow is at a point K (0 <= K <= 100,000) on the same number line. Farmer John has two modes of transportation: walking and teleporting. * Walking: FJ can move from any point X to the points X-1 or X+1 in a single minute * Teleporting: FJ can move from any point X to the point 2*X in a single minute. If the cow, unaware of its pursuit, does not move at all, how long does it take for Farmer John to retrieve it?

    农夫约翰被通知,他的一只奶牛逃逸了!所以他决定,马上幽发,尽快把那只奶牛抓回来.
    他们都站在数轴上.约翰在N(O≤N≤100000)处,奶牛在K(O≤K≤100000)处.约翰有
两种办法移动,步行和瞬移:步行每秒种可以让约翰从z处走到x+l或x-l处;而瞬移则可让他在1秒内从x处消失,在2x处出现.然而那只逃逸的奶牛,悲剧地没有发现自己的处境多么糟糕,正站在那儿一动不动.
    那么,约翰需要多少时间抓住那只牛呢?

傻逼宽搜。。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值