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. JAVA正则忽略大小写

    java正则表达式:  (?i)abc  表示abc都忽略大小写  a(?i)bc   表示bc忽略大小写  a((?i)b)c   表示只有b忽略大小写 也可以用Pattern.compile(re ...

  2. SQL Server2005 表分区三步曲(zz)

    前言 SQL Server 2005开始支持表分区,这种技术允许所有的表分区都保存在同一台服务器上.每一个表分区都和在某个文件 组(filegroup)中的单个文件关联.同样的一个文件/文件组可以容纳 ...

  3. float与double剖析

    今天研究下float与double的编码 float: 我们来看一下这组数是如何一步步从16进制转换到float的 float编码格式: 1.将16进制转换到2进制 整理后:0 1000 0010 1 ...

  4. 美好头标ToolBar

    ActionBar我相信是每一位合格的程序员都用过的组件,也是每一个程序员都会抱怨的组件,因为他不能实现复杂的自定义.为此Google推出了比ActionBar更为美好的组件ToolBar. 本文重点 ...

  5. mysql - 初探

    1,查询所有数据库名称: show databases; 2,查询所有表: use database_name; show tables; 3,查询表中的所有字段: desc table_name;

  6. Dell服务器MegaCli命令只返回Exit Code: 0x00问题分析

    今天同事给我说一台dell的服务器做了raid后,使用MegaCli看不到raid信息,上去看了一下确实不返回任何raid信息,但是确实机器上做了raid. 这就奇怪了,然后把MegaCli升级到最新 ...

  7. java项目测试log4j

    .literal { background-color: #f2f2f2; border: 1px solid #cccccc; padding: 1px 3px 0; white-space: no ...

  8. C++前置++与后置++的区别与重载

    ++属于单目运算符,前置与后置的实现代码不一样,下面以整数自增为例: // 前置++,返回自增后的值,且返回的是一个左值 int& operator++(){ *this += 1; retu ...

  9. MySQL的C++简单封装

    /* *介绍:MySQL的简单封装,支持流操作输入输出MySQL语句,然而并没有什么软用,大二学生自娱自乐,有不足求指点 *作者:MrEO *日期:2016.3.26 */ 头文件 my_sql.h ...

  10. pthread_setcanceltype 线程取消

    取消线程: (1)一个线程可以调用pthread_cancel来取消另一个线程.    (2)被取消的线程需要被join来释放资源.    (3)被取消的线程的返回值为PTHREAD_CANCELED ...