UESTC--1655
原题链接:http://acm.uestc.edu.cn/problem.php?pid=1655
分析:注意可能会反向。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define maxn 1005
#define inf 0x7fffffff
using namespace std;
int l[maxn],r[maxn];
int dis1[maxn];//clockwise
int dis2[maxn];//ante-clockwise
int ans[maxn];
int main()
{
int T,n,cas=,d;
cin>>T;
while(T--)
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&d);
r[i]=d;
if(i>=)l[i]=r[i-];
}
l[]=r[n];
for(int i=;i<=n;i++)
ans[i]=inf;
int s=;
while(s<=n)
{
dis1[s]=dis2[s]=;
int temp=;
for(int i=;i<n;i++)
{
int j=s+i;
if(j>n)j-=n;
temp+=l[j];
dis1[j]=temp;
}
ans[s]=min(ans[s],temp);
temp=;
for(int i=;i<n;i++)
{
int j=s-i;
if(j<=)j+=n;
temp+=r[j];
dis2[j]=temp;
}
ans[s]=min(ans[s],temp);
for(int i=;i<=n;i++)
if(i!=s)
{
int j=i+;
if(j>n)j-=n;
ans[s]=min(ans[s],dis1[i]*+dis2[j]);
j=i-;
if(j<=)j+=n;
ans[s]=min(ans[s],dis2[i]*+dis1[j]);
}
s++;
}
printf("Case #%d:",cas++);
for(int i=;i<=n;i++)
printf(" %d",ans[i]);
printf("\n");
}
return ;
}
UESTC--1655的更多相关文章
- ACM:UESTC - 649 括号配对问题 - stack
UESTC - 649 括号配对问题 Time Limit: 1000MS Memory Limit: 65535KB 64bit IO Format: %lld & %llu ...
- UESTC 1015 Lweb and pepper --前,后缀最值
题意: n种食物,每种含花椒的概率为Pi,现在已经选择了[L,R]这个区间(下标)的食物,要再选一个,使总的食物只有一种含花椒的概率最大,问选哪个最好,相同的选下标小的. 解法: 就不写解法了.此处有 ...
- UESTC 1852 Traveling Cellsperson
找规律水题... Traveling Cellsperson Time Limit: 1000ms Memory Limit: 65535KB This problem will be judged ...
- UESTC 1851 Kings on a Chessboard
状压DP... Kings on a Chessboard Time Limit: 10000ms Memory Limit: 65535KB This problem will be judged ...
- UESTC 30 最短路,floyd,水
最短路 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit Statu ...
- uestc oj 1218 Pick The Sticks (01背包变形)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可 ...
- uestc oj 1217 The Battle of Chibi (dp + 离散化 + 树状数组)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1217 给你一个长为n的数组,问你有多少个长度严格为m的上升子序列. dp[i][j]表示以a[i]结尾长为j ...
- 2015 CCPC D- Pick The Sticks(UESTC 1218) (01背包变形)
http://acm.uestc.edu.cn/#/problem/show/1218 既然二维dp表示不了,就加一维表示是否在边界放置,放置一个,两个.有一个trick就是如果只放一根,那么多长都可 ...
- 2015 CCPC-C-The Battle of Chibi (UESTC 1217)(动态规划+树状数组)
赛后当天学长就说了树状数组,结果在一个星期后赖床时才有了一点点思路…… 因为无法提交,不确定是否正确..嗯..有错希望指出,谢谢... 嗯..已经A了..提交地址http://acm.uestc.ed ...
- 2015 UESTC Winter Training #10【Northeastern Europe 2009】
2015 UESTC Winter Training #10 Northeastern Europe 2009 最近集训都不在状态啊,嘛,上午一直在练车,比赛时也是刚吃过午饭,状态不好也难免,下次比赛 ...
随机推荐
- 用Python实现检测视频真伪?
译者注:本文以一段自打24小时耳光的视频为例子,介绍了如何利用均值哈希算法来检查重复视频帧.以下是译文. 有人在网上上传了一段视频,他打了自己24个小时的耳光.他真的这么做了吗?看都不用看,肯定没有! ...
- ES6对数组的扩展
ECMAScript6对数组进行了扩展,为数组Array构造函数添加了from().of()等静态方法,也为数组实例添加了find().findIndex()等方法.下面一起来看一下这些方法的用法. ...
- 撤销 git merge
由于太多人问怎么撤销 merge 了,于是 git 官方出了这份教程,表示在 git 现有的思想体系下怎么达到撤销 merge 的目标. 方法一,reset 到 merge 前的版本,然后再重做接下来 ...
- Scrum立会报告+燃尽图(十月二十日总第十一次)
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2246 项目地址:https://git.coding.net/zhang ...
- 王者荣耀交流协会——第7次Scrum会议
照片由刘耀泽同学拍摄 ,王露芝同学(外援)没有参加本次会议. 要求2 : 时间跨度:2017年10月19日 15:05 - 15:20 共计15分钟 要求3 : 地点:计算机楼107教室 要求4 : ...
- 安装cocoa pods
1.移除现有Ruby默认源 $gem sources --remove https://rubygems.org/ 2.使用新的源 $gem sources -a https://ruby.taoba ...
- TCP系列43—拥塞控制—6、Congestion Window Validation(CWV)
一.概述 在RFC2861中,区分了TCP连接数据传输的三种状态 After sending a data segment: If tcpnow - T_last >= RTO ...
- 使用 TestNG 并发测试 ;
使用TestNG对IE /Chrome/firefox 进行兼容性并发测试 : package testNGTest; import org.openqa.selenium.By; import or ...
- 超强汇总!110 道 Python 面试笔试题
https://mp.weixin.qq.com/s/hDQrimihoaHSbrtjLybZLA 今天给大家分享了110道面试题,其中大部分是巩固基本python知识点,希望刚刚入手python,对 ...
- Git(未完待续)
Git的历史咱们就不多说来,我还是喜欢直白点,直接来干货吧 在Linux上安装Git 不同的系统不同的安装命令,基础的就不说来,centos直接yum就ok. 安装完成后,还需要最后一步设置,在命令行 ...