A.Phorni

题目:http://www.contesthunter.org/contest/CH%20Round%20%2351%20-%20Shinrein祭%20%231/Phorni

没做。。。

B.Arietta

题目:http://www.contesthunter.org/contest/CH%20Round%20%2351%20-%20Shinrein祭%20%231/Arietta

想到了网络流,所以每次暴力算出哪些点能被弹奏,就从这次弹奏向哪些点连容量为1的边

最后由s向所有力度连容量为该力度最多能被弹多少次的边,由每个节点连t容量为1的边

求最大流,得到了暴力分30分。正解还不会

代码:

 const inf=maxlongint;maxn=+;maxm=;
type node=record
go,next,v:longint;
end;
var tot,i,n,m,maxflow,l,r,s,t,x,y,tot2:longint;
h,head,head2,q,cur,v:array[..maxn] of longint;
e:array[..maxm] of node;
e2:array[..maxn] of node;
function min(x,y:longint):longint;
begin
if x<y then exit(x) else exit(y);
end;
procedure ins(x,y,z:longint);
begin
inc(tot);
e[tot].go:=y;e[tot].v:=z;e[tot].next:=head[x];head[x]:=tot;
end;
procedure insert(x,y,z:longint);
begin
ins(x,y,z);ins(y,x,);
end;
function bfs:boolean;
var i,x,y:longint;
begin
fillchar(h,sizeof(h),);
l:=;r:=;q[]:=s;h[s]:=;
while l<r do
begin
inc(l);
x:=q[l];
i:=head[x];
while i<> do
begin
y:=e[i].go;
if (e[i].v<>) and (h[y]=) then
begin
h[y]:=h[x]+;
inc(r);q[r]:=y;
end;
i:=e[i].next;
end;
end;
exit (h[t]<>);
end;
function dfs(x,f:longint):longint;
var i,y,used,tmp:longint;
begin
if x=t then exit(f);
used:=;
i:=cur[x];
while i<> do
begin
y:=e[i].go;
if (h[y]=h[x]+) and (e[i].v<>) then
begin
tmp:=dfs(y,min(e[i].v,f-used));
dec(e[i].v,tmp);if e[i].v<> then cur[x]:=i;
inc(e[i xor ].v,tmp);
inc(used,tmp);
if used=f then exit(f);
end;
i:=e[i].next;
end;
if used= then h[x]:=-;
exit(used);
end;
procedure dinic;
var i:longint;
begin
while bfs do
begin
for i:=s to t do cur[i]:=head[i];
inc(maxflow,dfs(s,inf));
end;
end;
procedure insert2(x,y:longint);
begin
inc(tot2);
e2[tot2].go:=y;e2[tot2].next:=head2[x];head2[x]:=tot2;
end;
procedure init;
begin
tot:=;
readln(n,m);
for i:= to n do begin read(x);insert2(x,i);end;readln;
for i:= to n do read(v[i]);readln;
end;
procedure dfss(x:longint);
var j,y:longint;
begin
if (v[x]>=l) and (v[x]<=r) then insert(i,x,);
j:=head2[x];
while j<> do
begin
y:=e2[j].go;
dfss(y);
j:=e2[j].next;
end;
end; procedure main;
begin
s:=;t:=n+m+;
for i:= to n do insert(i,t,);
for i:=n+ to n+m do
begin
readln(l,r,x,y);
insert(s,i,y);
dfss(x);
end;
maxflow:=;
dinic;
writeln(maxflow);
end; begin
init;
main;
end.

C。Falsita

题目:http://www.contesthunter.org/contest/CH%20Round%20%2351%20-%20Shinrein祭%20%231/Falsita

我下午刚做了POI的大都市,然后看到这题的对子树的修改就想到了用dfs序+线段树懒惰标记的做法,

最后回答的时候我是O(该点分叉数)求出总数,再用同样时间复杂度的时间求出总代价,使用子树和算的

我想出题人的要求回答询问的该点的分叉树一定很多,就会卡我到超时,结果真是的。。。

于是我又很愉快的拿到了30分。。。正解还不会

代码:

 const maxn=+;
type node=record
go,next:longint;
end;
node2=record
l,r,lch,rch,mid,tag,sum:int64;
end;
var e:array[..*maxn] of node;
t:array[..*maxn] of node2;
head,l,r,s,a,b:array[..*maxn] of longint;
i,n,m,x,y,tot,clock:longint;
ch:char;
procedure insert(x,y:longint);
begin
inc(tot);
e[tot].go:=y;e[tot].next:=head[x];head[x]:=tot;
end;
procedure dfs(x:longint);
var i,y:longint;
begin
inc(clock);l[x]:=clock;a[clock]:=x;
i:=head[x];
while i<> do
begin
y:=e[i].go;
dfs(y);
i:=e[i].next;
end;
inc(clock);r[x]:=clock;a[clock]:=x;
end;
procedure pushup(k:longint);
begin
with t[k] do
begin
sum:=t[lch].sum+t[rch].sum;
end;
end;
procedure build(k,x,y:longint);
begin
with t[k] do
begin
l:=x;r:=y;mid:=(l+r)>>;lch:=k<<;rch:=k<<+;tag:=;
if l=r then begin sum:=b[a[l]];exit;end;
build(lch,l,mid);build(rch,mid+,r);
pushup(k);
end;
end;
procedure update(k:longint;val:int64);
begin
with t[k] do
begin
inc(tag,val);
inc(sum,(r-l+)*val);
end;
end;
procedure pushdown(k:longint);
begin
with t[k] do
begin
if tag= then exit;
update(lch,tag);update(rch,tag);
tag:=;
end;
end;
procedure change(k,x,y:longint);
begin
with t[k] do
begin
if l=r then begin inc(sum,y);exit;end;
pushdown(k);
if x<=mid then change(lch,x,y) else change(rch,x,y);
pushup(k);
end;
end;
procedure change2(k,x,y:longint;z:int64);
begin
with t[k] do
begin
if (l=x) and (r=y) then
begin
update(k,z);exit;
end;
pushdown(k);
if y<=mid then change2(lch,x,y,z)
else if x>mid then change2(rch,x,y,z)
else
begin
change2(lch,x,mid,z);
change2(rch,mid+,y,z);
end;
pushup(k);
end;
end;
function query(k,x,y:longint):int64;
begin
with t[k] do
begin
if (l=x) and (r=y) then exit(sum);
pushdown(k);
if y<=mid then exit(query(lch,x,y))
else if x>mid then exit(query(rch,x,y))
else exit(query(lch,x,mid)+query(rch,mid+,y));
end;
end;
procedure init;
begin
readln(n,m);
for i:= to n do begin read(x);insert(x,i);end;readln;
for i:= to n do read(b[i]);readln;
dfs();
build(,,*n);
for i:= to n do s[i]:=(r[i]-l[i]+)>>;
end;
procedure getans;
var ans:double;
a,b,c:array[..maxn] of int64;
i,x,y,cnt:longint;
tot:int64;
begin
readln(x);a[]:=x;b[]:=s[x];c[]:=trunc(query(,l[x],r[x])/);
cnt:=;
i:=head[x];
while i<> do
begin
y:=e[i].go;
inc(cnt);
a[cnt]:=y;b[cnt]:=s[y];c[cnt]:=trunc(query(,l[y],r[y])/);
dec(c[],c[cnt]);
i:=e[i].next;
end;
tot:=b[]-;
for i:= to cnt do inc(tot,b[i]*(b[]-b[i]));
tot:=tot>>;
ans:=c[]*(b[]-)/tot;
for i:= to cnt do ans:=ans+c[i]*(b[]-b[i])/tot;
writeln(ans::);
end;
procedure main;
begin
for i:= to m do
begin
read(ch);
case ch of
'S':begin
readln(x,y);
change(,l[x],y);change(,r[x],y);
end;
'M':begin
readln(x,y);
change2(,l[x],r[x],y);
end;
'Q':getans;
end;
end;
end;
begin
init;
main;
end.

CH Round #51 - Shinrein祭 #1的更多相关文章

  1. CH Round #52 还教室[线段树 方差]

    还教室 CH Round #52 - Thinking Bear #1 (NOIP模拟赛) [引子]还记得 NOIP 2012 提高组 Day2 中的借教室吗?时光飞逝,光阴荏苒,两年过去了,曾经借教 ...

  2. CH Round #72树洞[二分答案 DFS&&BFS]

    树洞 CH Round #72 - NOIP夏季划水赛 描述 在一片栖息地上有N棵树,每棵树下住着一只兔子,有M条路径连接这些树.更特殊地是,只有一棵树有3条或更多的路径与它相连,其它的树只有1条或2 ...

  3. CH Round #30 摆花[矩阵乘法]

    摆花 CH Round #30 - 清明欢乐赛 背景及描述 艺术馆门前将摆出许多花,一共有n个位置排成一排,每个位置可以摆花也可以不摆花.有些花如果摆在相邻的位置(隔着一个空的位置不算相邻),就不好看 ...

  4. contesthunter CH Round #64 - MFOI杯水题欢乐赛day1 solve

    http://www.contesthunter.org/contest/CH Round %2364 - MFOI杯水题欢乐赛 day1/Solve Solve CH Round #64 - MFO ...

  5. CH Round #17 舞动的夜晚

    舞动的夜晚 CH Round #17 描述 L公司和H公司举办了一次联谊晚会.晚会上,L公司的N位员工和H公司的M位员工打算进行一场交际舞.在这些领导中,一些L公司的员工和H公司的员工之间是互相认识的 ...

  6. CH Round #45 能量释放

    能量释放 CH Round #45 - alan有一些陷阱 III 题目描述 alan得到一块由个能量晶体构成的矿石,对于矿石中的每一个能量晶体,如果用化学物质刺激某一个能量晶体,就能使它释放能量. ...

  7. CH Round #57 - Story of the OI Class 凯撒密码

    很有意思的一道题目 考场上想的是HASH成一个整数,把末位asicc码值*1,依次乘*10,得到一个整数,然后利用等差性.唯一性快排Nlogn乱搞的 证明如下: 对于明文abcde 密文 bcdef ...

  8. 判素数+找规律 BestCoder Round #51 (div.2) 1001 Zball in Tina Town

    题目传送门 /* 题意: 求(n-1)! mod n 数论:没啥意思,打个表能发现规律,但坑点是4时要特判! */ /***************************************** ...

  9. BestCoder Round #51 (div.2)

    明显是无良心的数学round= = 1000 Zball in Tina Town #include<iostream> #include<cstdio> #include&l ...

随机推荐

  1. javascript 高级程序设计(二)-在html中使用javascript

    <script> async 可选 charset 可选 defer 可选 language 已废弃 src 可选 type 可选

  2. vsftpd的主配置文件详解

    anonymous_enable=YES 允许匿名用户登录#local_enable=YES 允许本地用户登录#write_enable=YES 允许写权限#local_umask=022 ##ano ...

  3. JavaScript - 运算符 == 与 === 的区别

    在 JavaScript 中,运算符 == 与 === 都是用来比较两个值是否相等.但是这两个操作符有个不同的地方:== 并不表示严格相等,而 === 表示进行严格比较,不仅比较值,而且会比较变量的类 ...

  4. sql-从查询结果创建一个永久表

    语法: select x into new_tableName  from ori_tableName 例如: SELECT [site] ,[day] ,[val]/31.4 [val] into ...

  5. Plsql工具单步调试 存储过程或是 函数(oracle数据库)-留着自己用的

    <案例1> 原地址: http://jingyan.baidu.com/article/3a2f7c2e144d2826aed61167.html 调试过程对找到一个存过的bug或错误是非 ...

  6. iOS RC4加解密算法

    -(NSString *)encrypt:(NSString *)string withKey:(NSString *)key{ self.sBox = [[self frameSBox:key] m ...

  7. iOS Instruments之Core Animation动画性能调优(工具复选框选项介绍)

    Core Animation工具用来监测Core Animation性能.它给我们提供了周期性的FPS,并且考虑到了发生在程序之外的动画(见图12.4) Core Animation工具提供了一系列复 ...

  8. Objective - C 中NSString (字符串)与C中的字符串转换问题

    NSString是一个常用的类,NSString是原生支持unicode C中的字符串 比如char * a = "hello world";  是utf8类型的, char* d ...

  9. [转]Delphi执行CMD命令

    今天看到有人在问用代码执行CMD命令的问题,就总结一下用法,也算做个备忘. Delphi中,执行命令或者运行一个程序有2个函数,一个是winexec,一个是shellexecute.这两个大家应该都见 ...

  10. Java GC 日志输出分析

    搜到的几篇讲GC日志的文章,学到了很多东西.但是有些错误或者不够精确的地方. 因此自己尝试着总结一下. 先写个程序,然后结合程序解释每句话的意思. 运行参数 -Xms200M -Xmx200M -Xm ...