上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 28 下一页
摘要: 算是一道比较全面的模板题了吧,需要注意的是:查找比x小的元素个数时x不一定在Treap中,解决办法是插入x,查询,再删除x。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 stru... 阅读全文
posted @ 2015-08-02 14:59 hxy_has_been_used 阅读(254) 评论(0) 推荐(0) 编辑
摘要: Treap的入门题目,每个结点多维护一个size表示以它为根的子树的结点数,然后查kth的时候一层一层向下即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 struc... 阅读全文
posted @ 2015-08-02 10:26 hxy_has_been_used 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 又是一道树上做分组背包的题目... 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int INF = 999999999; 7 const int N = 2001; 8 int value[N]; 9 i... 阅读全文
posted @ 2015-08-01 20:33 hxy_has_been_used 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 最基本的在DAG上求最短路。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int INF = 999999; 7 const int N = 100001; 8 int dp[N]; 9 10 int m... 阅读全文
posted @ 2015-08-01 20:25 hxy_has_been_used 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 思路:记答案为ans,统计出数列A和B在某二进制某一位上有多少个1,如果个数相同,则ans那一位上为0(因为题目要求最小的满足条件的值),如果不一样(则需要考虑那一位上异或个1),则判断数列A在那一位上0的个数是否等于数列B那一位上1的个数,不等于则无解,否则,那一位上set为1,继续判断。 1 #... 阅读全文
posted @ 2015-08-01 20:09 hxy_has_been_used 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 很容易想到是最大匹配:行和列看做点,每一个可放置的位置看做边,先求一遍最大匹配,然后枚举删除每一条边,如果删除了某一条边发现求出来的最大匹配比之前少,则这条边对应的格点是”重要点“。 1 #include 2 #include 3 #include 4 using namespace std;... 阅读全文
posted @ 2015-08-01 09:08 hxy_has_been_used 阅读(170) 评论(3) 推荐(0) 编辑
摘要: 利用并查集建好图后:不断地求最大匹配、删除匹配边直到最大匹配不够n。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int N = 101; 8 bool mp[N]... 阅读全文
posted @ 2015-07-31 20:34 hxy_has_been_used 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 画一个图分析一下就清楚啦,应该优先考虑完成损失最大的作业,因为一天只能完成一门作业,而同时应该倒着从deadline往回找合适的完成时间,因为这样对于别的作业来说,它们有更多的机会被完成。另外,deadline的数据范围也是1000以内。 1 #include 2 #include 3 #inc... 阅读全文
posted @ 2015-07-31 20:00 hxy_has_been_used 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 判断是否存在欧拉(回)路,注意先要用并查集判断图是否连通。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 26; 7 const int M = 1001; 8 int f[N]; 9 in... 阅读全文
posted @ 2015-07-31 19:06 hxy_has_been_used 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 比较基础的线段树,1A。线段树: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 typedef long long ll; 7 const int N = 50001; 8 const int MOD ... 阅读全文
posted @ 2015-07-31 15:24 hxy_has_been_used 阅读(145) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 28 下一页