上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 42 下一页
View Code #include<iostream>using namespace std;class point{public : int x,y; point(); point(int x,int y); ~point();};void main(){ point p1; point p2(800,600); cout<<"p1: "<<p1.x<<" "<<p1.y<<endl; cout<<"p2: "<<p2.x<< Read More
posted @ 2011-12-07 10:38 Because Of You Views(243) Comments(0) Diggs(0) Edit
关键点:对每个箱子的dimension 排个序,这样才能判断某个箱子是否真的能放入另一个箱子内建好图后求一个图中的最长路即可View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int inf = 100000000;int box[510][1010];int map[510][510];int n,d;bool ok;int count=0;bool solve(int a,int b){ int i,j; bool flag=t Read More
posted @ 2011-12-06 22:01 Because Of You Views(395) Comments(0) Diggs(0) Edit
中文题目竟然理解错了题意关键点:等级差距大于m的两个人不能直接或间接交易,而1必须是图的终点,所以最短路径中所有的点的等级都必须在【level【1】-m,level【1】+m】之间,所以可以枚举等级限制,for(i=level[1]-m;i<=level[1];i++){ 最短路算法且要保证 最短路径中每个点的等级都在【i,i+m】之间}就这样,带血的AC总是那么的鼓舞人心View Code #include<stdio.h>#include<string.h>#include<stdlib.h>const int inf = 1000000000;i Read More
posted @ 2011-12-06 12:31 Because Of You Views(446) Comments(0) Diggs(0) Edit
View Code import java.io.*;import java.util.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int t, n, i; int dp[] = new int[100000]; t = cin.nextInt(); int cases=0; while (t > 0) { t--; ... Read More
posted @ 2011-12-05 14:16 Because Of You Views(445) Comments(0) Diggs(0) Edit
一百题留念,继续加油 Read More
posted @ 2011-12-03 18:53 Because Of You Views(299) Comments(0) Diggs(0) Edit
View Code class trie{public: int num; trie *child[26]; trie() { num=0; memset(child,0,sizeof(child)); }}root;int insert(char *s){ class trie *cur=&root; int len=strlen(s); for(int i=0;i<len;i++) { int id=s[i]-'a'; if(!cur->child[id]) ... Read More
posted @ 2011-12-03 18:42 Because Of You Views(320) Comments(0) Diggs(0) Edit
提交了很多次,不想多说了第一种方法非常暴力View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>using namespace std;int num,tot;int cnt[2011];int map[2011][2011];char dic[2011][20];struct node{ char s[20];}ans[2011];bool cmp(node a,node b){ return strcmp(a.s,b.s)<0; Read More
posted @ 2011-12-03 18:34 Because Of You Views(366) Comments(0) Diggs(0) Edit
建议先做poj 2481http://poj.org/problem?id=2481我的详细解答http://www.cnblogs.com/wuyiqi/archive/2011/09/20/2182986.html这道题目就是加了点东西,每个区间的数据范围变为32位,不离散化的话树状数组保存不下来所以先进行离散化,按照poj 2481的做法,不通的地方是,只按x排序后对x坐标进行离散化,即依次按x从小到大把把各个排序后的区间标记为1,2,3.。。。就相当于所有的x的坐标都变为了1~n的数,这样做不会影响结果,因为x间的相互关系还是不变的随后再进行一次排序,跟poj2481一样了,不再赘述V Read More
posted @ 2011-12-02 12:32 Because Of You Views(255) Comments(0) Diggs(0) Edit
跟上一道题差不多,拆分单词,这里是不断把后缀加进字典树,但要注意同一个字母的两个或两个以上相同前缀只能算一个,所以在插入时要多传入一个参数记录传入字符串所属单词的编号,如果某个节点上一次也是由这个单词产生的,则只记一次就好View Code #include<stdio.h>#include<string.h>#include<math.h>class trie{public: int num; int pre; trie *child[26]; trie() { num=0; pre=-1; memset(child,0... Read More
posted @ 2011-12-01 22:12 Because Of You Views(321) Comments(0) Diggs(0) Edit
任务:输出所有可以由其他两个单词组成的单词如题目中的ahat有a和hat组成做法:建立好字典树后拆分单词,把单词分成两段,再在字典树中查找这两段单词是否存在,如果存在就输出,注意输出后要break掉,就这样。View Code #include<stdio.h>#include<string.h>#include<math.h>class trie{public: bool flag; trie *child[26]; trie() { flag=false; memset(child,0,sizeof(child)); }}root;... Read More
posted @ 2011-12-01 21:47 Because Of You Views(341) Comments(0) Diggs(0) Edit
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 42 下一页