上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 31 下一页

2015年12月26日

CDOJ 1259 昊昊爱运动 II bitset+线段树

摘要: 题目链接昊昊喜欢运动他N天内会参加M种运动(每种运动用一个[1,m]的整数表示)现在有Q个操作,操作描述如下昊昊把第l天到第r天的运动全部换成了x(x∈[1,m])问昊昊第l天到第r天参加了多少种不同的运动Input输入两个数N,M(1≤N≤105,1≤M≤100);输入N个数ai(ai∈[1,m]... 阅读全文

posted @ 2015-12-26 14:39 yohaha 阅读(260) 评论(0) 推荐(0) 编辑

codeforces 508D . Tanya and Password 欧拉通路

摘要: 题目链接 给你n个长度为3的子串, 这些子串是由一个长度为n+2的串分割得来的, 求原串, 如果给出的不合法, 输出-1。 一个欧拉通路的题, 将子串的前两个字符和后两个字符看成一个点, 比如acb, 就是ac->cb。 然后建图。 1 #include <iostream> 2 #include 阅读全文

posted @ 2015-12-26 13:41 yohaha 阅读(146) 评论(0) 推荐(0) 编辑

poj 1041 John's trip 欧拉回路

摘要: 题目链接 求给出的图是否存在欧拉回路并输出路径, 从1这个点开始, 输出时按边的升序输出。 将每个点的边排序一下就可以。 1 #include <iostream> 2 #include <vector> 3 #include <cstdio> 4 #include <cstring> 5 #inc 阅读全文

posted @ 2015-12-26 11:59 yohaha 阅读(143) 评论(0) 推荐(0) 编辑

2015年12月24日

poj 1651 Multiplication Puzzle 区间dp

摘要: 题目链接给一串数, 拿出一个数i的代价是a[i-1]*a[i]*a[i+1], 第一个数和最后一个数不能拿, 求拿走剩下的数的代价的最小值。#include #include #include #include #include #include #include #include #include... 阅读全文

posted @ 2015-12-24 10:22 yohaha 阅读(176) 评论(0) 推荐(0) 编辑

poj 2955 Brackets 区间dp

摘要: 题目链接给一堆括号, 问最多有多少个是匹配的。依然是区间dp, 直接记忆化搜索就可以。#include #include #include #include #include #include #include #include #include #include using namespace s... 阅读全文

posted @ 2015-12-24 09:33 yohaha 阅读(125) 评论(0) 推荐(0) 编辑

codeforces 607B. Zuma 区间dp

摘要: 题目链接给一个长度为n的序列, 每一次可以消去其中的一个回文串, 问最少几次才可以消完。代码很清楚#include #include #include #include #include #include #include #include #include #include using names... 阅读全文

posted @ 2015-12-24 09:00 yohaha 阅读(243) 评论(0) 推荐(0) 编辑

2015年12月23日

hdu 4638 Group 莫队算法

摘要: 题目链接很裸的莫队, 就不多说了... 1 #include 2 using namespace std; 3 #define pb(x) push_back(x) 4 #define ll long long 5 #define mk(x, y) make_pair(x, y) 6 #define... 阅读全文

posted @ 2015-12-23 23:38 yohaha 阅读(350) 评论(0) 推荐(0) 编辑

codeforces 551E. GukiZ and GukiZiana 分块

摘要: 题目链接 给出n个数, m个操作, 每个操作有两种, 将一段区间加上某个值, 或者询问一个k, a[i] = a[j] = k, 输出满足条件的最大的j-i, 如果没有输出-1。 做法是将数组分块, 第一次做这种, 抄的codeforces上面的代码... #include<bits/stdc++. 阅读全文

posted @ 2015-12-23 21:13 yohaha 阅读(263) 评论(0) 推荐(0) 编辑

codeforces 557D. Vitaly and Cycle 二分图染色

摘要: 题目链接 n个点, m条边, 问最少加几条边可以出现一个奇环, 在这种情况下, 有多少种加边的方式。 具体看代码解释 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define pb(x) push_back(x) 4 #define ll 阅读全文

posted @ 2015-12-23 16:36 yohaha 阅读(175) 评论(0) 推荐(0) 编辑

poj 2135 Farm Tour 费用流

摘要: 题目链接给一个图, N个点, m条边, 每条边有权值, 从1走到n, 然后从n走到1, 一条路不能走两次,求最短路径。如果(u, v)之间有边, 那么加边(u, v, 1, val), (v, u, 1, val), val是路的长度,代表费用, 1是流量。 1 #include 2 #inc... 阅读全文

posted @ 2015-12-23 13:02 yohaha 阅读(147) 评论(0) 推荐(0) 编辑

上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 31 下一页

导航