随笔分类 -  UVa题解

1 2 3 下一页

UVa-1218 - Perfect Service
摘要:d[u][0][1]=sum{d[v][0]}d[u][1][1]=d[u][1][0]=sum{min(d[v][0],d[v][1])}d[u][0][0]=sum{d[v][0]}-d[min][0]+d[min][1] (d[min][1]=min(d[v][1]))调了很久。。。。 看到... 阅读全文

posted @ 2015-09-18 01:26 windrises 阅读(235) 评论(0) 推荐(0)

Uva-1220 - Party at Hali-Bula
摘要:树的最大独立集,但是要判断唯一性。有些像是dfs。另外发现std::ios::sync_with_stdio(0)不能与scanf并用! 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #define pb pu... 阅读全文

posted @ 2015-09-13 15:12 windrises 阅读(227) 评论(0) 推荐(0)

UVa-10003 - Cutting Sticks
摘要:区间dp,O(n^3)的算法很容易想。先递增枚举区间的长度d,再枚举起点i,再枚举切点k(i 2 #include 3 #include 4 using namespace std; 5 const int maxn=55; 6 int l,n; 7 int p[maxn]; 8 int dp[ma... 阅读全文

posted @ 2015-09-10 00:52 windrises 阅读(217) 评论(0) 推荐(0)

UVa-1625 - Color Length
摘要:这道题我硬是做了两天多。dp比较好写,但是预处理很难写。自己第一次没写出来,看lrj的,结果反而越看越发愣。但还是受了点启发,改用c[i][j]来表示第一个字符串拿出前i个,第二个字符串拿出前j个时有多少种字母是已经开始了,但还没有结束。 然后又因为memset而超时了,学到的教训就是如果大部... 阅读全文

posted @ 2015-09-05 17:11 windrises 阅读(316) 评论(2) 推荐(0)

UVa-11584 - Partitioning by Palindromes
摘要:先用manacher找到以所有回文串,再暴力统计以每个字符为结尾的所有回文串,然后dp就容易了。最坏情况下是O(n^2) (之后看了一下,这题的时间发现居然是rank 4!) 1 #include 2 #include 3 #include 4 #include 5 #include 6 #defi... 阅读全文

posted @ 2015-09-03 18:20 windrises 阅读(331) 评论(0) 推荐(0)

UVa-12563 - Jin Ge Jin Qu hao
摘要:最近一直在做dp的题,上周六的BC简直惨不忍睹,就做出来一道题最后还FST了。不管了,暂时还是少刷一些比赛吧。好久没有更新了。集训结束了,太弱,没劲去写感想。在学校待到26号,然后回家,9.2再来。 1 #include 2 #include 3 #include 4 using namespace... 阅读全文

posted @ 2015-08-24 13:15 windrises 阅读(410) 评论(3) 推荐(0)

UVa-12166 Equilibrium Mobile
摘要:被多校虐的不要不要的,不过集训也过去一(大)半了吧。这道题前几天写了一下,感觉好麻烦就暂时没写了。今天又拿起来看一下,除了写错一个变量名导致WA了一发外,算是1Y吧,还是感觉很爽的。下面是我的代码。后来又看了别人的题解,有的是暴力枚举每一个点做的,比我的要好理解,不过我的时间复杂度肯定要低。还有一个... 阅读全文

posted @ 2015-08-07 20:15 windrises 阅读(509) 评论(0) 推荐(0)

UVa-10129 - Play on Words
摘要:欧拉回路,然后dfs判断是否联通。(新技能get)注意:在dfs判断是否联通的时候,要是写成有向图的话,则一定要从起点进行dfs,有不少博主写错了,由于这题UVa的数据貌似不强,所以也AC了==我写的是无向图。 1 #include 2 #include 3 #include 4 using nam... 阅读全文

posted @ 2015-07-24 23:43 windrises 阅读(228) 评论(0) 推荐(0)

UVa-839 - Not so Mobile
摘要:在没有读完数据的时候,不能在中间就退出dfs。很好的一道题。 1 #include 2 #include 3 #include 4 using namespace std; 5 bool dfs(int &w) 6 { 7 int w1,d1,w2,d2; 8 scanf("%d%d... 阅读全文

posted @ 2015-07-24 13:52 windrises 阅读(154) 评论(0) 推荐(0)

UVa-679 - Dropping Balls
摘要:直接模拟会超时 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxx=21; 6 int d,n; 7 bool f[1 2 #include 3 #include 4 using namespace std... 阅读全文

posted @ 2015-07-24 11:34 windrises 阅读(176) 评论(0) 推荐(0)

UVa-12657 - Boxes in a Line
摘要:用数组写感觉萌萌哒啊,本题可以写个link函数,更加方便 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxx=100010; 6 int r[maxx],l[maxx]; 7 int n,m; 8 long... 阅读全文

posted @ 2015-07-24 01:22 windrises 阅读(229) 评论(0) 推荐(0)

UVa-11988 - Broken Keyboard (a.k.a. Beiju Text)
摘要:原来数组可以代替指针,涨姿势 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxx=100010; 6 char a[maxx]; 7 int next[maxx],cur,last; 8 int main(... 阅读全文

posted @ 2015-07-24 01:21 windrises 阅读(166) 评论(0) 推荐(0)

UVa-140 - Bandwidth
摘要:决定跳过数据结构那章,来看暴力求解法。暴力这章之前也看过,可是前几天做了一道POJ的暴力题,却没有想起来自己曾经在书上看过类似的暴力枚举解法,所以决定再仔细看一遍。感觉要是不刷题,只是单纯的看书的话,记不住啊。书中也说了,可以剪枝(“发现两个结点的距离大于或等于k”,“如果在搜索到结点u时,u结点还... 阅读全文

posted @ 2015-07-20 00:12 windrises 阅读(185) 评论(0) 推荐(0)

UVa-230 - Borrowers
摘要:终于在UVa上AC了50题了,感觉还有很长的路要走!!!这道题有点麻烦,还是用STL写的。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxx=1010; 8 t... 阅读全文

posted @ 2015-07-17 21:26 windrises 阅读(749) 评论(0) 推荐(0)

UVa-10317 - Equating Equations
摘要:一个即将高一的网友问的我的题。汗,我怎么大一才接触编程!用STL写的,当时UVa挂了,没有去测试。之后发现TLE了,把vector改成数组依然如此。一时没想到怎么解决,先这样吧,以后再看看。 1 #include 2 #include 3 #include 4 #include 5 #include... 阅读全文

posted @ 2015-07-17 20:57 windrises 阅读(160) 评论(2) 推荐(0)

UVa-1595 - Symmetry
摘要:在看了别人的代码后发现有很多可以避免出现精度问题的方法(如坐标都乘2等) 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxx=1010; 7 const double eps=1e-5... 阅读全文

posted @ 2015-07-17 01:47 windrises 阅读(237) 评论(0) 推荐(0)

UVa-10391 - Compound Words
摘要:继续用STL写,虽然比较耗时,但是简洁方便,不容易出错。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 const int maxx=1200... 阅读全文

posted @ 2015-07-17 01:45 windrises 阅读(148) 评论(0) 推荐(0)

UVa-10763 - Foreign Exchange
摘要:掌握了新姿势 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxx=500010; 7 int a[maxx],b[maxx]; 8 int main() 9 {10 //fre... 阅读全文

posted @ 2015-07-17 01:44 windrises 阅读(276) 评论(0) 推荐(0)

UVa-10935 - Throwing cards away I
摘要:简单的队列。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int main() 7 { 8 //freopen("in.in","r",stdin); 9 //freopen("out.in... 阅读全文

posted @ 2015-07-17 01:41 windrises 阅读(150) 评论(0) 推荐(0)

UVa-1594 - Ducci Sequence
摘要:学到了新姿势,对结构体用map,set,sort等,可以在结构体中重载小于号(也有别的方式,没有仔细研究。)。注意const偷懒不加的话会通不过编译。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace s... 阅读全文

posted @ 2015-07-17 01:40 windrises 阅读(480) 评论(0) 推荐(0)

1 2 3 下一页

导航