Contest 9
A:搜索好难啊根本不会啊。
B:暴力枚举给哪段前缀乘,维护一些前后缀最大最小值之类的东西就很好算了。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 1000010
#define ll long long
int n,w,v,a[N];
ll ans=-,sum[N],pre[N],suf[N];
int main()
{
freopen("game.in","r",stdin);
freopen("game.out","w",stdout);
n=read(),w=-read(),v=-read();
for (int i=;i<=n;i++) a[i]=read();
for (int i=;i<=n;i++) sum[i]=sum[i-]+a[i];
for (int i=;i<=n+;i++) pre[i-]=suf[i]=(sum[n]-sum[i-])*v+sum[i-];
for (int i=;i<=n;i++) pre[i]=max(pre[i],pre[i-]);
for (int i=n;i;i--) suf[i]=min(suf[i],suf[i+]);
for (int i=;i<=n;i++)
ans=max(ans,min(sum[i]*w+suf[i+]-sum[i],(sum[n]-sum[i])*v+(pre[i]-(sum[n]-sum[i])*v)*w));
cout<<ans;
return ;
}
C:吐槽一下这场的心路历程。开场看A,看了一会性质发现转化成了一个2-SAT,这玩意怎么还能计数啊?盯了一个小时一点都不会,暴力都没写就跑了。心态从这就开始崩了。然后半个小时搞掉B。C开始胡乱分析一下觉得某结论很显然,然后写了一个小时差不多搞定了,结果因为各种写挂,大样例跑的比答案大。然而并没有冷静下来去验证结论,并且由于数据范围才50觉得自己肯定假掉了,于是开始退火。退了半天总是比答案小,到处找锅没有任何收获,最后弃疗了连交都没交了。之后调了两个小时才发现做mst时边权开的是int于是炸成负数了。
这个题胡乱分析一下性质跑mst就好了。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<ctime>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 55
#define T1 1e5
#define T2 1e-8
#define delta 0.98
int n,a[N][N],b[N][N],id[N],id2[N],dfn[N],fa[N],c;
long long t[N],u[N],f[N],tmp[N],dis[N][N],ans,tot=;
bool cmp(const int&a,const int&b)
{
return f[a]>f[b];
}
struct data
{
int x,y;long long z;
bool operator <(const data&a) const
{
return z<a.z;
}
}edge[N*N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void SWAP(int x,int y)
{
swap(id[x],id[y]);
dfn[id[x]]=x,dfn[id[y]]=y;
}
long long getans()
{
ans=;
for (int i=;i<=n;i++) fa[i]=i;
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
if (a[i][j]) fa[find(i)]=find(j);
for (int i=;i<=n;i++)
{
for (int j=;j<=n;j++)
if (a[i][j])
if (dfn[j]<dfn[i]) ans+=u[j]*f[i]*(u[i]-t[i]);
else if (dfn[j]>dfn[i]) ans+=t[j]*f[i]*(u[i]-t[i]);
ans+=f[i]*((u[i]-)+t[i])*(u[i]-t[i])>>;
}
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
dis[i][j]=;
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
if (dfn[i]<dfn[j])
{
int p=find(i),q=find(j);
if (p!=q) dis[p][q]=min(dis[p][q],(t[i]+t[j])*c+t[j]*f[i]*(u[i]-t[i])+u[i]*f[j]*(u[j]-t[j]));
}
int cnt=;memset(id2,,sizeof(id2));
for (int i=;i<=n;i++) if (find(i)==i) id2[++cnt]=i;
int num=;
for (int i=;i<=cnt;i++)
for (int j=;j<=cnt;j++)
num++,edge[num].x=id2[i],edge[num].y=id2[j],edge[num].z=dis[id2[i]][id2[j]];
sort(edge+,edge+num+);
for (int i=;i<=n;i++) fa[i]=i;
for (int i=;i<=num;i++)
if (find(edge[i].x)!=find(edge[i].y)) ans+=edge[i].z,fa[find(edge[i].x)]=edge[i].y;
return ans;
}
void solve()
{
double T=T1;
long long lastans=tot;
while (T>T2)
{
int x=rand()%(n-)+,y=rand()%(n-x)+x+;
SWAP(x,y);
ans=getans();
if (ans<lastans||exp((lastans-ans)/T)>1.0*rand()/RAND_MAX) tot=min(tot,ans);
else SWAP(x,y),ans=lastans;
T*=delta;lastans=ans;
}
}
int main()
{
freopen("reconstruction.in","r",stdin);
freopen("reconstruction.out","w",stdout);
n=read();srand(time());
for (int i=;i<=n;i++) t[i]=read();
for (int i=;i<=n;i++) u[i]=read();
for (int i=;i<=n;i++) f[i]=read();
if (n==) {cout<<(f[]*((u[]-)+t[])*(u[]-t[])>>);return ;}
for (int i=;i<=n;i++)
{
for (int j=;j<=n;j++)
{
char c=getchar();
while (c!='Y'&&c!='N') c=getchar();
if (c=='Y') a[i][j]=;
}
}
c=read();
for (int i=;i<=n;i++) id[i]=i;
sort(id+,id+n+,cmp);
for (int i=;i<=n;i++) dfn[id[i]]=i;
tot=getans();
//solve();
cout<<tot;
return ;
}
result:- rank-
Contest 9的更多相关文章
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu 4946 2014 Multi-University Training Contest 8
Area of Mushroom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2016 Multi-University Training Contest 2 D. Differencia
Differencia Time Limit: 10000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- 2016 Multi-University Training Contest 1 G. Rigid Frameworks
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- hdu-5988 Coding Contest(费用流)
题目链接: Coding Contest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- ZOJ 3703 Happy Programming Contest
偏方记录背包里的物品.....每个背包的价值+0.01 Happy Programming Contest Time Limit: 2 Seconds Memory Limit: 65536 ...
- 2012 Multi-University Training Contest 9 / hdu4389
2012 Multi-University Training Contest 9 / hdu4389 打巨表,实为数位dp 还不太懂 先这样放着.. 对于打表,当然我们不能直接打,这里有技巧.我们可以 ...
- 2014 Multi-University Training Contest 9#11
2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others) ...
- 2014 Multi-University Training Contest 9#6
2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...
- 校际联合Contest
每次开一个坑都像是重新被碾压的预感 最近的新闻,以前很喜欢乔任梁的<复活>...然后他就死了...感觉我再多愁善感一点的话...就要悲伤逆流成河了吧... Contest 09/24(乐滋 ...
随机推荐
- 【LG5021】[NOIP2018]赛道修建
[LG5021][NOIP2018]赛道修建 题面 洛谷 题解 NOIP之前做过增强版还没做出来\(QAQ\) 一看到题目中的最大值最小,就很容易想到二分答案 重点是考虑如何\(check\) 设\( ...
- CF 1064 D. Labyrinth
D. Labyrinth http://codeforces.com/contest/1064/problem/D 题意: n*m的矩阵,只能往左走l次,往右走r次,上下走无限制,问能走到多少个点. ...
- LVS入门篇(五)之LVS+Keepalived实战
一.实验架构和环境说明 (1)本次基于VMware Workstation搭建一个四台Linux(CentOS 7.4)系统所构成的一个服务器集群,其中两台负载均衡服务器(一台为主机,另一台为备机), ...
- 【linux】vim常用快捷键(转)
原文链接:https://www.cnblogs.com/tianyajuanke/archive/2012/04/25/2470002.html 1.vim ~/.vimrc 进入配置文件 如果不知 ...
- springmvc传参---LocalDateTime、Date等时间类型转换
此处定义的dateConvert用来转换Date类型,如果是LocalDate.LocalDateTime类型,则将Date类型换成相应的类型即可,注意java8的日期类型需要用Formatter格式 ...
- IncDec序列:差分+贪心
IncDec序列 题目描述: 给定一个长度为 n 的数列 a1,a2,…,an,每次可以选择一个区间[l,r],使下标在这个区间内的数都加一或者都减一. 求至少需要多少次操作才能使数列中的所有数都一样 ...
- hive 2以上版本启动异常 Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
hive2.0以上的版本启动时 抛出 “Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreCli ...
- Echarts数据可视化全解
点击进入 Echarts数据可视化全解
- Ubuntu16.04下 protobuf3.4.0 的安装与卸载
感谢原文作者:https://blog.csdn.net/xiexievv/article/details/47396725 一. 安装 下载protobuf protobuf下载地址:https:/ ...
- fast-IO
代码: int Scan() //输入外挂 { ,ch,flag=; if((ch=getchar())=='-') flag=; ') res=ch-'; ') res=res*+ch-'; ret ...