自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Detective_Xin的专栏

分布式计算,海量数据处理,算法与数据结构

  • 博客(154)
  • 资源 (1)
  • 收藏
  • 关注

原创 POJ题目分类

献给有志于认真学习算法的同学!!! POJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094) 初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)

2012-01-22 19:01:24 761

原创 LeetCode Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the tota

2014-07-21 14:19:07 830

原创 LeetCode Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ["aa"

2014-07-21 14:16:51 709

原创 LeetCode Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]

2014-07-21 14:14:21 743

原创 LeetCode Single Number

Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using e

2014-07-21 11:09:48 618

原创 LeetCode Same Tree

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 判断

2014-07-21 11:02:49 647

原创 LeetCode Sort List

Sort a linked list in O(n log n) time using constant space complexity. 对链表进行排序,要求时间复杂度为

2014-07-21 10:47:03 602

原创 LeetCode Convert Sorted List to Binary Search Tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 把有序链表转换为

2014-07-21 10:40:04 665

原创 LeetCode Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra space?

2014-07-21 10:38:00 627

原创 uva 270 Lining Up

给出一系列二位坐标上的点,统计最多有多少个点在同一条直线上,暴力枚举n^3 #include #include struct Line { int no_slope; double k; double i_x; double i_y; //b }; struct Point { double x; double y; }; const double E = 1e-6; bool

2013-11-25 16:24:58 859

原创 uva 231 Testing the CATCHER

题目很长,其实就是个最长单调子序列的问题。 #include int data[1000]; int dp[1000]; int get_max(int a, int b) { if (a>b) return a; else return b; } int main() { int n; int i,j,tmp; int case_ctr=0; int flag=0; w

2013-11-25 16:22:33 887

原创 uva 190 Circle Through Three Points

计算几何的题目,三点确定一个圆。 #include #include struct Line { int no_slope; double k; double i_x; double i_y; }; struct Point { double x; double y; }; const double E = 1e-5; bool double_cmp(double a, doub

2013-11-25 16:20:58 1070

原创 uva 147 Dollars

完全背包问题,输出为方案总数。 #include #include const int SIZE=11; int items[SIZE]={2000,1000,400,200,100,40,20,10,4,2,1}; int total = 6010; long long dp[6010]; int main() { double m; int i,j; memset

2013-11-25 15:31:22 767

原创 uva 122 Trees on the level

题目要求按层次输出数的各个节点,其实只要对输入的数据做个排序就可以了。 #include using namespace std; #include #include #include struct Node { string v; string path; }; Node nodes[300]; set v_set; set p_set; int get_(string s) {

2013-11-22 13:19:27 1715

原创 uva 120 Stacks of Flapjacks

模拟题 #include #include #include using namespace std; int ori[40]; int sorted[40]; int data[40]; int n; vector result; bool is_sorted() { int i; for (i=0;i<n-1;i++) { if (data[i]>data[i+1]) r

2013-11-22 13:17:25 753

原创 UVA 111 History Grading

最长公共子序列 #include #include int correct[30]; int stu[30]; int dp[30][30]; int get_max(int a, int b) { if (a>b) return a; else return b; } int main() { int n,i,j; int tmp; scanf("%d",&n);

2013-11-22 13:14:40 831

原创 UVA 108 Maximum Sum

最大子矩阵和,转化为一维最大字串和解决 #include #include int n; int data[120][120]; int column_sum[120]; int max_sum[120]; void set_column_sum(int r1, int r2) { memset(column_sum,0,sizeof(column_sum)); int i,

2013-11-22 13:12:58 876

原创 UVA 103 Stacking Boxes

记忆化搜索 #include #include #include #include using namespace std; struct Box { int index; vector dimensions; }; // 判断b2是否可以包含b1 bool cmp(const Box& b1, const Box& b2) { int i; for (i=0;i<b1.di

2013-11-22 13:07:02 888

原创 UVA 101 The Blocks Problem

直接模拟四个操作 #include using namespace std; #include #include vector data[30]; int n; void move_onto(int a, int b) { int row_a, row_b; int i, j; if (a==b) return; for (i=0;i<n;i++) { for (j=0;j

2013-11-22 13:05:21 795

原创 URAL 1022 Genealogical Tree

拓扑排序 #include using namespace std; #include #include int n; int topology[120][120]; vector result; bool zoro_out_degree(int index) { // bool flag = true; for (int i = 1;i <= n; i++) { if (topol

2013-11-22 13:04:06 828

原创 URAL 1014 Product of Digits

给定一个整数N,找出最小的正整数Q,使得Q的各位数的积等于N。 直接深搜 #include using namespace std; #include #include int flag; vector result; void dfs(int num) { if (flag==1) return; if (num < 10) { result.push_back(num);

2013-11-22 13:02:29 1114

原创 URAL 1005 Stone Pile

给出一堆石头,要求将石头分成两堆,是得两堆石头的和的差值最小。 转化为01背包问题求解,设sum为所有石头的权值和,则背包容量为sum/2。 #include #include int w[30]; int dp[1000020]; int get_max(int a, int b) { if(a>=b) return a; else return b; } int main

2013-11-22 12:59:41 1885

原创 Sicily 1211 商人的宣传

Floyd算法 #include #include #include int road[120][120]; long long result[120][120]; int main() { int n,m,l; int x,y,q; int i,j,k; while (scanf("%d",&n)!=EOF) { scanf("%d%d",

2013-11-22 12:52:35 1620

原创 Sicily 1034 Forest

广搜找森林的深度和宽度 #include #include #include #include using namespace std; int is_visited[110]; int forest[110][110]; int all_level_width[110]; int flag; int n; int depth, width; vector roots; void add

2013-11-22 12:51:10 1865

原创 Sicily 1158 Pick numbers

广搜找权值最小的路径 #include #include #include using namespace std; int matrix[12][12]; int n,m; struct Node { int row, col; int num; }; int BFS() { deque q; Node tmp; Node next; tm

2013-11-22 12:47:28 857

原创 Sicily 1346 金明的预算方案

依赖背包,转为01背包+分组背包 #include #include #include using namespace std; int dp[3220]; struct Item { int id; int v,p; }; int n,m; Item items[70]; vector add_items[70]; int add_items_dp[70][3220];

2013-11-22 12:43:53 1726

原创 Sicily 1750 运动会

分组背包问题 #include #include using namespace std; #include #include int p,n; int dp[120][1200]; struct Item { int energy; int award; }; int get_max(int a, int b) { if (a>b) return

2013-11-22 12:39:31 1242

原创 Sicily 1077 Cash Machine

多重背包问题 #include #include #include using namespace std; int dp[100010]; vector items; int get_max(int a, int b) { if (a>b) return a; else return b; } int main() { int to

2013-11-22 12:38:10 851

原创 Sicily 1099 Packing Passengers

欧几里得解线性方程 #include #include long long Extended_Euclid(long long a,long long b,long long& x,long long& y) { if(b==0){ x=1; y=0; return a; } long long d=Extended_E

2013-11-22 11:34:00 918

原创 Sicily 1140 国王的遗产

贪心,主要卡在划分树的子树上。#include using namespace std; #include #include #include #include #include vector tree[30002]; int node_ctr[30002]; int n,k; vector result; int set_node_ctr(int root) { if (n

2013-11-22 11:32:00 1707

原创 Sicily 1048 Inverso

按照题意广搜,注意输入"wwwwwwwww"时输出11就可以了。 #include using namespace std; #include #include #include #include deque q; int parent[512]; int parent_step[512]; int flip1(bitset b) { b.flip(9-1); b.fl

2013-11-22 11:30:09 1078

原创 Sicily 1135 飞越原野

广度优先搜索,三维数组判重 #include #include #include using namespace std; struct Node { int x,y,p; }; char matrix[120][120]; //at (x,y) with z power int visited[120][120][120]; int n,m,d; int dir[4][2]={{

2013-11-22 11:19:36 1804

原创 Sicily 2014 Dairy Queen

完全背包 #include #include int dp[320]; int n,c; int coins[10]; int main() { int i,j; while (scanf("%d",&n)!=EOF) { scanf("%d",&c); for (i=0;i<c;i++) scanf("%d"

2013-11-22 11:17:46 1354

原创 Sicily 1685 Missile

DP,最长单调子序列的变形。 #include int dp[1010][2]; int nums[1010]; int get_max(int a, int b) { if (a>b) return a; else return b; } int main() { int i,j,n; int ans; scanf("%d",&n); while (n!=0) { f

2013-11-22 11:14:10 869

原创 More Effective C++

Item M1:指针和引用的区别 引用必须总是指向某个对象,任何情况下都不能使用指向空值的引用,不存在指向空值的引用意味着使用引用的代码效率比使用指针高,因为使用引用之前不需要测试引用的合法性。 指针可以被重新赋值指向另一个不同的对象,引用则一直指向初始化时指向的对象,以后都不能改变。 string s1("nancy"); string s2("clancy"); string &rs =

2012-12-12 20:06:50 632

原创 ArchLinux上搭建Twitter Storm平台

主机上安装的是64位的Arch系统,相关的CPU信息和内存信息如下: 4 Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz MemTotal: 16322984 kB MemFree: 14513576 kB Buffers: 136332 kB Cached: 1393720 kB 基本依赖

2012-10-28 14:42:20 2435

转载 centos的twitter storm安装和storm-start的本地运行

这里介绍一下storm的基本安装和不用lein的storm-starter运行方法。 一. Storm及相关软件安装 1. 安装python2.7.2 ============================ # wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz # tar zxvf Python-2.7

2012-10-10 23:11:11 2485

转载 NoSQL:列存储数据库之HBase

Hbase是bigtable的开源山寨版本。是建立的hdfs之上,提供高可靠性、高性能、列存储、可伸缩、实时读写的数据库系统。   它介于nosql和RDBMS之间,仅能通过主键(row key)和主键的range来检索数据,仅支持单行事务(可通过hive支持来实现多表join等复杂操作)。主要用来存储非结构化和半结构化的松散数据。   与hadoop一样,Hbase目标主要依靠横向扩

2012-09-25 14:09:48 2547

转载 从Hadoop框架与MapReduce模式中谈海量数据处理(淘宝技术架构)

从hadoop框架与MapReduce模式中谈海量数据处理 前言     几周前,当我最初听到,以致后来初次接触Hadoop与MapReduce这两个东西,我便稍显兴奋,觉得它们很是神秘,而神秘的东西常能勾起我的兴趣,在看过介绍它们的文章或论文之后,觉得Hadoop是一项富有趣味和挑战性的技术,且它还牵扯到了一个我更加感兴趣的话题:海量数据处理。     由此,最近凡是空

2012-09-22 00:02:29 1166

转载 动态规划时间规整简介入门

在日常的生活中我们最经常使用的距离毫无疑问应该是欧式距离,但是对于一些特殊情况,欧氏距离存在着其很明显的缺陷,比如说时间序列,举个比较简单的例子,序列A:1,1,1,10,2,3,序列B:1,1,1,2,10,3,如果用欧氏距离,也就是distance[i][j]=(b[j]-a[i])*(b[j]-a[i])来计算的话,总的距离和应该是128,应该说这个距离是非常大的,而实际上这个序列的图像是十

2012-09-17 11:16:40 9975

ACM国际大学生程序设计竞赛试题与解析

ACM的相关资料,献给有志于在这方面有所突破的童鞋们

2011-04-13

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除