随笔分类 -  解题报告

摘要:题意:每个顶点有一个权值,求构造一个图,使得 ∑(每个点的权值)X(到1结点的距离) 最小方法:dijkstra+heap昨晚写了一个,不知道为什么TLE,怎么改都TLE。今天重写一遍AC了#include<cstdio>#include<queue>#include<cstring>using namespace std;#define MAXN 50005#define MAXM 100005#define INF 10000000000int edge_cnt;int val[MAXN];int first[MAXN];struct edge_node 阅读全文
posted @ 2012-05-05 09:43 laputastar 阅读(253) 评论(0) 推荐(0)
摘要:题意:给一个有向图,告诉起点和终点,求第K短路解法:dijkstra+A*,正反两个邻接表总结:做完这个题学会了dijkstra算法,对A*有了一点了解PS.优先队列里的比较函数变量写错了,MLE了3天,恶心死我了。膜拜无语神牛,几分钟就指导我搞定了/*Problem: 2449 User: fancy081Memory: 6472K Time: 250MSLanguage: C++ Result: Accepted*/#include<cstdio>#include<queue>#include<cstring>using namespace std;co 阅读全文
posted @ 2011-10-01 01:20 laputastar 阅读(451) 评论(0) 推荐(0)
摘要:1010: The Almost Lucky NumbersTime Limit:1 SecMemory Limit:128 MBSubmit:16Solved:11[Submit][Status][Web Board]DescriptionJohn and Brus believe that the digits 4 and 7 are lucky and all others are not. According to them, an almost lucky number is a number that contains at most one non-lucky digit in 阅读全文
posted @ 2011-08-04 10:42 laputastar 阅读(338) 评论(0) 推荐(0)
摘要:1003: 狗狗和花生Time Limit:1 SecMemory Limit:128 MBSubmit:10Solved:4[Submit][Status][Web Board]Description有n只狗狗,为了训练狗狗玩花生的能力,主人制定了三种命令:1.g i:表示第i只狗狗得到一颗花生2.e i:表示让第i只狗狗吃掉它得到的所有花生3.s i j:表示让第i只狗狗和第j只狗狗交换各自的花生主人给定了k个命令,作为一套命令,为了巩固训练效果,狗狗们需要将这套命令重复m遍……Input先输入T,表示输入T个测试数据,对于每个测试数据:第1行:整数n,m,k(n<=10,m< 阅读全文
posted @ 2011-07-30 00:12 laputastar 阅读(329) 评论(0) 推荐(0)
摘要:1027: 教你前缀Time Limit:1 SecMemory Limit:128 MBSubmit:29Solved:6[Submit][Status][Web Board]Description什么是前缀你懂吧,不懂?那我告诉你,假如串S1和S2长度分别是len1,len2,len1<=len2且S2的前len1个字母和S1一样,则S1是S2的前缀。CJR不是在给叶老师做项目嘛,今天遇到一个小问题,找到wuyu,wuyu也不会做,那就请教你来了。叶老师给他很多全是英文小写字母字符串,要她统计一下这里面有多少个串可以做其他串的前缀,重复的串只统计一次。Input正整数n,(n< 阅读全文
posted @ 2011-07-30 00:06 laputastar 阅读(214) 评论(0) 推荐(0)
摘要:最基本的树状数组操作,卡了半天,是因为为了节省几KB内存,树状数组用了short存,导致结果错误!!#include<stdio.h>#include<string.h>short a[100005];int c[100005],n;int lowbit(int i){ return i&(-i);}void add(int i,int v){ while (i<=n) { c[i]+=v; i+=lowbit(i); }}int sum(int i){ int s=0; while (i>0) { s+=c[i]; i-=lowbit(i); } 阅读全文
posted @ 2011-07-28 21:10 laputastar 阅读(264) 评论(0) 推荐(0)
摘要:Prime PathTime Limit:1000MSMemory Limit:65536KTotal Submissions:6010Accepted:3440DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a matter of security to 阅读全文
posted @ 2011-07-28 12:56 laputastar 阅读(189) 评论(0) 推荐(0)