原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1242代码:#include<iostream>#include<queue>#include<memory.h>using namespace std;int row,col;char map[201][201];int startX,startY,endX,endY;int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};struct Node{ int x,y,count;};int visit[201][201];Node N, Read More
posted @ 2013-05-24 21:45 supersnow0622 Views(150) Comments(0) Diggs(0)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241代码:#include <iostream>using namespace std;int row,col;char map[101][101];int dir[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};void dfs(int i,int j){ int newr,newc; map[i][j]='*'; for(int k=0;k<8;k++) { newr=i+dir[k] Read More
posted @ 2013-05-24 21:43 supersnow0622 Views(128) Comments(0) Diggs(0)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312代码:#include <iostream>using namespace std;int row,col;char map[101][101];int dir[8][2]={{-1,0},{1,0},{0,-1},{0,1}};int startX,startY;int count;void dfs(int i,int j){ int newr,newc; map[i][j]='#'; for(int k=0;k<8;k++) { newr=i+dir[k] Read More
posted @ 2013-05-24 21:41 supersnow0622 Views(161) Comments(0) Diggs(0)
原题链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=27代码:01.#include <stdio.h>02.#include<string.h>03.int check[4][2]={{0,-1},{1,0},{0,1},{-1,0}};04.int arr[100][100];05.int row,col;06.void dfs(int r,int c)07.{08.int newr,newc;09.arr[r][c]=0;10.for(int i=0;i<4;i++)11.{12.newr=r+chec Read More
posted @ 2013-05-18 19:08 supersnow0622 Views(137) Comments(0) Diggs(0)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2084解题思路:从下向上计算手工模拟样例:i代表行j代表列,arr【】用来存储第i行第j列位置自下而上的最大和 1 2 3 4 5 第一行 7 arr【1】【1】=7+23=30 ---------------->arr[1][1]处为最大和第二行 3 8 arr【2】【1】=3+20=23,arr【2】【2】=8+13=21第三行 8 1 0 arr【3】【1】=8+12=20(12是经过和7的比较得到大的一个),arr【3】【2】=1+12=13,... Read More
posted @ 2013-04-10 23:59 supersnow0622 Views(138) Comments(0) Diggs(0)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1025 求最长上升子序列的长度解题思路:用二分查找法手工模拟:比如求序列5 6 7 1 2 8 3的最长上升子序列的长度。 data【】数组存储原始数据,dp【】数组存储最长递增序列,max表示目前递增序列的最大长度 data【1】=5 初始化:dp【0】=-1,dp【1】=data【1】=5,max=1。从索引为2处开始查找比较: data【2】=6第一次查找比较后dp【0】=-1,dp【1】=5,dp【2】=6,max=2; data【3】=7第二次查找比较后dp【0】=-1,dp【1】=5.. Read More
posted @ 2013-04-10 23:44 supersnow0622 Views(102) Comments(0) Diggs(0)
位图排序是一种效率极高(复杂度可达O(n))并且很节省空间的一种排序方法,但是这种排序方法对输入的数据是有比较严格的要求(数据不能重复,大致知道 数据的范围)。位图排序即利用位图或者位向量来表示集合。举个例子,假如有一个集合{3,5,7,8,2,1},我们可以用一个8位的二进制向量 set[1-8]来表示该集合,如果数据存在,则将set相对应的二进制位置1,否则置0.根据给出的集合得到的set为 {1,1,1,0,1,0,1,1},然后再根据set集合的值输出对应的下标即可得到集合{3,5,7,8,2,1}的排序结果。这个就是位图排序的原 理。一.位图排序的应用: 1.给40亿个不重复的un. Read More
posted @ 2013-04-05 22:15 supersnow0622 Views(162) Comments(0) Diggs(0)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159#include<iostream>#include<string.h>using namespace std;char a[1001],b[1001];int num[1001][1001];int main(){ while(cin>>a>>b) { memset(num,0,sizeof(num)); int i,j; int len1=strlen(a),len2=strlen(b); for(i=0;i<len1;i++) { f Read More
posted @ 2013-04-03 23:07 supersnow0622 Views(85) Comments(0) Diggs(0)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087#include<stdio.h>#include<memory.h>int main(){ int count; int arr[1001],sum[1001]; scanf("%d",&count); int max; while(count!=0) { memset(sum,0,sizeof(sum)); for(int i=0;i<count;i++) { scanf("%d",&arr[i]); s Read More
posted @ 2013-04-03 23:04 supersnow0622 Views(112) Comments(0) Diggs(0)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1003#include<stdio.h>struct Node{ int max; int start; int end;};int arr[100001];Node node[100001];int main(){ int count,num,Max; scanf("%d",&count); for(int cases=1;cases<=count;cases++) { scanf("%d",&num); scanf(&qu Read More
posted @ 2013-04-03 23:01 supersnow0622 Views(133) Comments(0) Diggs(0)