07 2013 档案

D - Judgment Day
摘要:题目链接:HERE由于N≤10,可以暴力求出所有取出名字的可能情况,其中符合要求的取出个数最多的便是所求答案。有一个显而易见的剪枝就是当前取出的名字长度之和大于God手中的Long String 的长度时,该分枝便不可能符合要求,直接结束即可。AC Code: 1 #include 2 #include 3 #include 4 const long M=110000; 5 char s[M]; 6 long letter[30],name[20][30],vis[30],t,n,ans,s_len; 7 long len[20]; 8 void judge(long now){ 9 ... 阅读全文

posted @ 2013-07-30 22:43 SCNUACM 阅读(241) 评论(0) 推荐(0)

C - 子序列个数
摘要:题目链接:Here设ans[i]为以前i个数为结尾的序列的总数,last[x]为以数x为结尾,长度大于1的序列的总数,vis[x]表示数x是否出现过,第i个数a[i]=x。若x没有出现过,则以第i个数为结尾的序列的个数为 ans[i-1]+1 (以 前i个数为结尾的序列后面加上一个x,在加上一个长度为1的序列x)若x出现过,则以第i个数为结尾的序列的个数为 ans[i-1]-last[x] (以 前i个数为结尾的序列后面加上一个x,但因为x曾经出现过,所以减去重复的部分last[x],另外取模的时候要注意加上mod。然后更新last[x]的值,显然这个值为 ans[i-1].最后ans[n]即 阅读全文

posted @ 2013-07-30 22:41 SCNUACM 阅读(395) 评论(0) 推荐(0)

B - A Simple Tree Problem
摘要:题目链接:猛戳这里题目大意:给一棵多叉树,初始值都为0,o x为翻转以x为根的子树,q x为查询以x为根的子树有多少个1思路:这数据范围,暴力是不行的,怎么暴力都是不行的>__ 2 #include 3 4 const int MAX = 100010; 5 6 int flip[MAX*4], sum[MAX*4], cnt[MAX*4];//tree 7 int head[MAX], next[MAX], to[MAX], ecnt; 8 int beg[MAX], size[MAX], dfs_clock; 9 int y1, y2; 10 11 void tle... 阅读全文

posted @ 2013-07-30 22:36 SCNUACM 阅读(246) 评论(0) 推荐(0)

B. Binary Operations
摘要:题目链接:戳这里记n个数为a[0],a[1],...,a[n-1],由于取的是连续片段,故我们可以以末尾元素为分类依据进行讨论。显然,以a[i](i=0,...,n-1)为末尾的子序列有i+1个,分别为:a[i],a[i-1]a[i],...,a[0]a[1]...a[i].故总的个数为all=1+2+...+n=n*(n+1)/2.考虑到a[i](i=0,...,n-1)的取值范围为[0,10^9] 2 #include 3 using namespace std; 4 5 int main(){ 6 int T,t,i,j; 7 long long n,temp=1,a[... 阅读全文

posted @ 2013-07-29 16:14 SCNUACM 阅读(223) 评论(0) 推荐(0)

F. Journey
摘要:题目链接:这儿题目大意:给一棵树T,每条边都有一个权值,然后又一条新增边,多次询问:从点x到点y在T上走的最短距离,在加上那条新增边之后,最短距离可以减少多少。思路:任意确定一个根root,DFS计算每个点到根的距离dis[],然后每两点间的最短距离为 dis[x]+dis[y]-2*dis[LCA(x,y)]。若新加入一条边u--v,那么如果我们必须经过u--v,那么从x到y的最短距离就为 dis(x,u)+dis(u,v)+dis(v,y)或dis(x,v)+dis(v,u)+dis(u,y)。这样在线处理答案就行。PS:至于求LCA的方法可以参考2007年郭华阳的论文《RMQ&L 阅读全文

posted @ 2013-07-28 17:02 SCNUACM 阅读(320) 评论(0) 推荐(0)

D. Divide
摘要:题目链接:戳这里思路:用一个数组记录下每个二进制位上的值,满2进位,从高位到低位扫一遍,找到不能被均分的最高位(当前位为1而且不是进位获得的),该位置代表的值减去比它低位的值就是答案了AC Code: 1 #include 2 #include 3 #include 4 #define LL long long 5 const long M=110000; 6 LL pos[M],JinWei[M],ans[M],max_pos; 7 long n,t; 8 int main(){ 9 scanf("%d",&t);10 for (long l=1;l1){26 . 阅读全文

posted @ 2013-07-28 16:57 SCNUACM 阅读(224) 评论(0) 推荐(0)

A. A Big Dinner
摘要:题目链接:猛戳这儿题意:求三个数的全排列AC Code: 1 #include 2 #include 3 #include 4 using namespace std; 5 long a[10],t; 6 long cmp(long x,long y){ 7 return x<y; 8 } 9 int main(){10 scanf("%d",&t);11 for (long i=1;i<=t;++i){12 for (long j=1;j<=3;++j)13 scanf("%d",&a[j]);14 sor... 阅读全文

posted @ 2013-07-28 16:52 SCNUACM 阅读(192) 评论(0) 推荐(0)

E - The Fortified Forest
摘要:原题链接:点击打开题目大意:有n棵树,每棵树有坐标(x,y),价值v,长度l,问如何砍能砍掉最小价值为的树(价值相同则砍最少的树),能把其他树都围起来思路:枚举所有砍树的方案(我用的递归,用二进制的方法理论上来说也可以),算一下能不能围起剩下的树(如果价值比当前答案要大就不用算了)。至于怎么围起剩下的树,一个点的明显是需要0长度,两个点就需要这两个点的距离*2,三个点或以上就要用到求凸包的方法(反正我的凸包是不能算三个点以下的)PS:输出最好复制啊,我好像就是因为forest打错了WA了好几次啊……AC Code: 1 #include 2 #include 3 #include ... 阅读全文

posted @ 2013-07-24 10:01 SCNUACM 阅读(325) 评论(0) 推荐(0)

D -Sale
摘要:原题链接:点击打开大水题,题目我看不懂,不过看样例好像是把最小的m个负数(不要正数)加起来取反就好了,直接上代码AC Code: 1 #include 2 #include 3 using namespace std; 4 5 int a[110]; 6 7 int main() { 8 int n, m; 9 scanf("%d%d", &n, &m);10 for(int i = 0; i = 0) break;15 ans += a[i];16 }17 printf("%d\n", -ans);18 }By 区彦开 阅读全文

posted @ 2013-07-24 09:59 SCNUACM 阅读(145) 评论(0) 推荐(0)

B - Collisions
摘要:题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26830#problem/B题目大意:直线上有n个不计半径的球,有初始坐标和速度,给出公式,问第t秒这些球分别在哪些位置思路:有点麻烦的水题,大致上就是每次算出两个球相撞的最小时间mint,然后计算出mint秒后球球们分别都在什么位置,相撞的都要计算速度(注意:同一时间可能有多对球同时碰撞,我用一个WA证实了这一点……)。还有要注意的事,比如速度相等的、位置相同的球不能用来算最小时间,理由自己想。还有算出来时间不是正数也不能要,不是正数说明两个球没外力干扰的情况下永远不会相撞 阅读全文

posted @ 2013-07-24 09:53 SCNUACM 阅读(195) 评论(0) 推荐(0)

E - Two Teams
摘要:E - Two TeamsTime Limit:1000MSMemory Limit:65536KB64bit IO Format:%I64d & %I64uSubmitStatusPracticeURAL 1106DescriptionThe group of people consists ofNmembers. Every member has one or more friends in the group. You are to write program that divides this group into two teams. Every member of each 阅读全文

posted @ 2013-07-19 23:38 SCNUACM 阅读(359) 评论(1) 推荐(0)

D - Flying to the Mars
摘要:D - Flying to the Mars Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1800DescriptionIn the year 8888, the Earth is ruled by the PPF Empire . As the population growing , PPF needs to find more land for the newborns . Finally , PPF decides to attac 阅读全文

posted @ 2013-07-19 23:30 SCNUACM 阅读(287) 评论(1) 推荐(0)

B - Wealthy Family
摘要:B -Wealthy FamilyTime Limit:10000MSMemory Limit:0KB64bit IO Format:%lld & %lluSubmitStatusPracticeUVALive 5741DescriptionWhile studying the history of royal families, you want to know how wealthy each family is. While you have various 'net worth' figures for each individual throughout hi 阅读全文

posted @ 2013-07-19 10:08 SCNUACM 阅读(250) 评论(0) 推荐(0)

A - Volleyball
摘要:A -VolleyballTime Limit:2000MSMemory Limit:262144KB64bit IO Format:%I64d & %I64uSubmitStatusPracticeCodeForces 96DDescriptionPetya loves volleyball very much. One day he was running late for a volleyball match. Petya hasn't bought his own car yet, that's why he had to take a taxi. The ci 阅读全文

posted @ 2013-07-19 10:04 SCNUACM 阅读(339) 评论(3) 推荐(0)

导航