04 2016 档案

摘要:Tree2cycle dfs 不是根节点:如果边数大于等于2,则删除与父节点的边。并且是一条环,那么每个点的度数是2,则还要删除num(每个节点儿子数)-2,只留两个儿子。当然删除边的儿子也要连到环上,又是一个num(每个节点儿子数)-2次操作。最后不同分支之间还要连一条边。所以复杂度为:2*(nu 阅读全文
posted @ 2016-04-24 00:10 yyblues 阅读(388) 评论(0) 推荐(0) 编辑
摘要:模拟,注意为偶数的情况 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<iostream> 5 #include<queue> 6 #include<stack> 7 #include<cmath> 8 #i 阅读全文
posted @ 2016-04-23 22:58 yyblues 阅读(260) 评论(0) 推荐(0) 编辑
摘要:水题。。直接暴力 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 const int inf = 0x3f3f3f3f; 5 int a[130][130],d,n,x,y,z,num,ans=-inf; 6 int 阅读全文
posted @ 2016-04-23 22:57 yyblues 阅读(151) 评论(0) 推荐(0) 编辑
摘要:借鉴大神思路。。。 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<iostream> 5 #include<queue> 6 #include<stack> 7 #include<cmath> 8 #inc 阅读全文
posted @ 2016-04-23 22:32 yyblues 阅读(232) 评论(0) 推荐(0) 编辑
摘要:总体思路好想,就是在找K个不同字母的时候,卡时间。 看了大神代码,发现goto的!!!!998ms 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<iostream> 5 #include<queue> 6 阅读全文
posted @ 2016-04-22 23:43 yyblues 阅读(247) 评论(0) 推荐(0) 编辑
摘要:B题。。。水题,记录当前行是由原矩阵哪行变来的。 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<iostream> 5 #include<queue> 6 #include<stack> 7 #includ 阅读全文
posted @ 2016-04-22 22:16 yyblues 阅读(194) 评论(0) 推荐(0) 编辑
摘要:水题。。。就是n的三进制后m位 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<iostream> 5 #include<queue> 6 #include<stack> 7 #include<cmath> 阅读全文
posted @ 2016-04-22 22:13 yyblues 阅读(203) 评论(0) 推荐(0) 编辑
摘要:与HDU 1907一样。。。 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<iostream> 5 #include<queue> 6 #include<stack> 7 #include<cmath> 8 阅读全文
posted @ 2016-04-21 16:59 yyblues 阅读(291) 评论(0) 推荐(0) 编辑
摘要:博弈入门题吧。 把尼姆博弈推广到n堆,都是用异或运算。还有个总结的地方是,只要先手面对的是奇异局势,则胜负都掌握在后手。本题,题目要求是最后拿完的输,尼姆博弈是最后拿完的赢。但实际上优先权都掌握在后手,前提是先手面对的是奇异局势。 本题还要注意一下每堆都是1的情况。 最后还是膜拜一下OI大神,推荐一 阅读全文
posted @ 2016-04-21 16:02 yyblues 阅读(219) 评论(0) 推荐(0) 编辑
摘要:思路:从后往前一位一位的模拟,每次判断一下当前枚举的数是否之间枚举过了。或者当前枚举数过小,小于1989. 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<iostream> 5 #include<queue 阅读全文
posted @ 2016-04-20 21:42 yyblues 阅读(229) 评论(0) 推荐(0) 编辑
摘要:这种题代码都写残。。。。 思路就是先把每个数都记为1,统计正负数的和sum,如果sum大于n,则负数和q减1,加的时候类似。注意限制条件 比较水的题。。。。 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<i 阅读全文
posted @ 2016-04-20 20:23 yyblues 阅读(249) 评论(0) 推荐(0) 编辑
摘要:水题。。[a,b]区间数的最大公约数。 a==b输出a 否则输出1 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<stack> 6 #include<cmath> 7 阅读全文
posted @ 2016-04-18 22:23 yyblues 阅读(280) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/acdreamers/article/details/7626671 学习一下Dilworth定理 推荐一篇写得很好博客 要求最少的覆盖,按照Dilworth定理 最少链划分 = 最长反链长度 所以最少系统 = 最长导弹高度上升序列长度。 之前写的LIS模板 阅读全文
posted @ 2016-04-18 22:07 yyblues 阅读(216) 评论(0) 推荐(0) 编辑
摘要:计算几何中的精度问题(转)(谢谢原创) 计算几何头疼的地方一般在于代码量大和精度问题,代码量问题只要平时注意积累模板 一般就不成问题了。精度问题则不好说,有时候一个精度问题就可能成为一道题的瓶颈,简直“画龙点睛”。这些年的题目基本是朝着越来越不卡精度的方向发展 了,但是也不乏一些%^&%题#$%$^ 阅读全文
posted @ 2016-04-17 23:09 yyblues 阅读(671) 评论(0) 推荐(0) 编辑
摘要:思路:三角形的圆心角可以整除(2*pi)/n 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<stack> 6 #include<algorithm> 7 using n 阅读全文
posted @ 2016-04-17 22:11 yyblues 阅读(261) 评论(0) 推荐(0) 编辑
摘要:思路:直接用求(b,1)范围内互质的数,(a-1,1)范围内互质的数。再求反 就是敲一下容斥模板 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<stack> 6 #in 阅读全文
posted @ 2016-04-17 17:36 yyblues 阅读(240) 评论(0) 推荐(0) 编辑
摘要:树的分治学了好几天时间也不是很透彻,特别是09年OI论文还没看懂。。。。。 这题很经典的一道树的分治 可以参考09漆神OI论文 1 #include <cstdio> 2 #include <algorithm> 3 #include <vector> 4 #include <cstring> 5 阅读全文
posted @ 2016-04-16 19:29 yyblues 阅读(213) 评论(0) 推荐(0) 编辑
摘要:dp[i][j]表示i到j需要添加的长度 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<stack> 6 using namespace std; 7 #define 阅读全文
posted @ 2016-04-15 20:23 yyblues 阅读(288) 评论(0) 推荐(0) 编辑
摘要:求树的重心,直接当模板吧。先看POJ题目就知道重心什么意思了。。。 重心:删除该节点后最大连通块的节点数目最小 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<stack 阅读全文
posted @ 2016-04-14 22:40 yyblues 阅读(315) 评论(0) 推荐(0) 编辑
摘要:思路:这题就是学习一下算法优化,选择最优方案,O(nm) 可以学习一下《浅谈数据的合理组织》这篇论文 详见代码 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<stack 阅读全文
posted @ 2016-04-14 16:20 yyblues 阅读(250) 评论(0) 推荐(0) 编辑
摘要:简单树形DP 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<cstdlib> 5 using namespace std; 6 int n,w[6001],ne=0; 7 bool in[6001]; 8 阅读全文
posted @ 2016-04-13 23:09 yyblues 阅读(237) 评论(0) 推荐(0) 编辑
摘要:思路:首先一定是2^m次方的总数。用二进制从 000 一直到 111总过m个数,然后暴搜。 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<stack> 6 #inclu 阅读全文
posted @ 2016-04-13 19:40 yyblues 阅读(219) 评论(0) 推荐(0) 编辑
摘要:一个奶牛有两个选择方案,要么A成立B不成立,要么A不成立则B成立。所以可以2——sat建图,然后每个方案检查一下就行。 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<s 阅读全文
posted @ 2016-04-13 15:12 yyblues 阅读(303) 评论(0) 推荐(0) 编辑
摘要:题意:给你一个哈密顿图,判断是不是平面图 思路:先找出哈密顿图来。哈密顿回路可以看成一个环,把边集划分成两个集合,一个在环内,一个在外。如果有两条相交边在环内,则一定不是平面图,所以默认两条相交边,转化成2——sat,两条边不能同时在内或外,注意双向加边。(以边来转化成两倍) 1 #include< 阅读全文
posted @ 2016-04-13 00:43 yyblues 阅读(267) 评论(0) 推荐(0) 编辑
摘要:算法指南 就是从飞机早着陆还晚着路两种状态可以组合成一个点,类似2--sat把一个点划分成两个点来表示状态,再二分时间,如果小于时间则可以转化成相应的约数条件:“xi或xj为假”这样的条件。 1 #include<cstdio> 2 #include<cstring> 3 #include<iost 阅读全文
posted @ 2016-04-11 23:11 yyblues 阅读(250) 评论(0) 推荐(0) 编辑
摘要:题意:询问多少个矩形。 统计横纵坐标差,放进vector中 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<stack> 6 #include<bits/stdc++.h 阅读全文
posted @ 2016-04-11 14:56 yyblues 阅读(203) 评论(0) 推荐(0) 编辑
摘要:维护一个左右区间指针就可以。 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 #include<stack> 6 using namespace std; 7 int main(){ 8 阅读全文
posted @ 2016-04-11 14:06 yyblues 阅读(204) 评论(0) 推荐(0) 编辑
摘要:有多种方案,找拐点数目最简单O(n) 注意此题有相邻点价值一样,代码改变一点 1 #include <cstdio> 2 #include<iostream> 3 #include<cstdlib> 4 #include<algorithm> 5 int s,n,k,i,a,b; 6 int mai 阅读全文
posted @ 2016-04-10 22:37 yyblues 阅读(168) 评论(0) 推荐(0) 编辑
摘要:水题:直接判断素数+bfs 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <sstream> 5 #include <algorithm> 6 #include <list> 7 #include 阅读全文
posted @ 2016-04-08 22:47 yyblues 阅读(163) 评论(0) 推荐(0) 编辑
摘要:题意:给出一个整数n,(1 <= n <= 200)。求出任意一个它的倍数m,要求m必须只由十进制的'0'或'1'组成。 思路:直接深搜。网上还有DFS+同余模定理 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #i 阅读全文
posted @ 2016-04-07 23:29 yyblues 阅读(174) 评论(0) 推荐(0) 编辑
摘要:题意:有一个M*N的棋盘,每一个格子只有两种状态0或1,每次可以选择一个格子执行翻转操作,并且与该格子相邻的4个格子都会被翻转,求将所有格子都翻转成0所需要的最小操作数,若有多种方案,输出字典序最小的方案数。 思路:枚举第一行的状态,深搜接下来每行。此题由上往下搜,所以直接搜四个方向就可以,当前格子 阅读全文
posted @ 2016-04-07 16:12 yyblues 阅读(280) 评论(0) 推荐(0) 编辑
摘要:三维空间里BFS最短路 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <sstream> 5 #include <string> 6 #include <algorithm> 7 #include 阅读全文
posted @ 2016-04-06 22:44 yyblues 阅读(228) 评论(0) 推荐(0) 编辑
摘要:简单搜索 练习一下回溯 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <sstream> 5 #include <string> 6 #include <algorithm> 7 #include 阅读全文
posted @ 2016-04-06 21:48 yyblues 阅读(168) 评论(0) 推荐(0) 编辑
摘要:先枚举行再DP列。好题,详见代码 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <climits> 5 #include <vector> 6 #include <iostream> 7 using 阅读全文
posted @ 2016-04-06 19:34 yyblues 阅读(337) 评论(0) 推荐(0) 编辑
摘要:求最短路径覆盖的全部边权值和。 思路:分别从起点和终点两次求最短路,再比较两个点到起点的距离和他们之间的权值相加和是否等于最短路径。 这题很好 1 #include <cstring> 2 #include <cmath> 3 #include <queue> 4 #include <vector> 阅读全文
posted @ 2016-04-05 21:52 yyblues 阅读(276) 评论(0) 推荐(0) 编辑
摘要:题意:有n个人,m种需求,给出m行,每行a,b代表a想要的书在b那里,问能不能通过交换的方法来满足每个人的需求 思路:要符合题意的话一定是二分图。网上还一种dfs 1 #include<cstdio> 2 #include<iostream> 3 #include<cstdlib> 4 #inclu 阅读全文
posted @ 2016-04-05 21:25 yyblues 阅读(186) 评论(0) 推荐(0) 编辑
摘要:题意:M×N的矩阵 让你保持每行每列的大小对应关系不变,将矩阵重写,重写后的最大值最小。 思路:离散化思想+并查集,详见代码 好题! 1 #include <iostream> 2 #include <string.h> 3 #include <stdio.h> 4 #include <algori 阅读全文
posted @ 2016-04-01 00:20 yyblues 阅读(316) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示