Colorful Day
日历
网志分类
· 所有网志
· 〖 个人日记 〗
· 〖 程序设计 〗
· 〖 ACM-ICPC 〗
· 〖 IT信息 〗
· 〖 人文科学 〗
· 〖 灰色空间 〗
· 〖 贴图世界 〗
最新的评论
站内搜索
友情链接
· 我的歪酷 非非共享界
· 麻省理工学院开放式课件
· 中国计算机教学网
· 计算机学院FTP
· CSDN
· HDOJ
· ZOJ
· Linle
· JGShining

订阅 RSS

0010124

歪酷博客

Imagenation
Never Lose My Passion
It's On My Way , It's On My Way
Colorful Day....
威士忌 @ 2006-07-22 12:52

一眨眼暑假就过去了22天
这些天一直只是在看书
还是没法好好AC
先得好好把基础加强一下了



 
威士忌 @ 2006-07-17 21:38

/************************************
CSuffixTree类有CreatTree,Show,Search,PrintNode四个方法,主要讨论CreatTree及Search方法.

CreatTree:通过两层循环查找目标字符串的每一个前缀的所有后缀,
通过调用Search方法将结果分为四种。通过switch分别处理四种情况。

Search:搜索函数,通过遍历搜索参数传入的字符串。
将搜索结果通过point指针及其指向的节点的breakpoint变量,left字符串,
以及函数返回值影响CreatTree的处理方法。

************************************/

#include <vector>
#include <iostream>
#include <string>
#include <stack>
#include <deque>

using namespace std;

typedef struct node//声明节点的结构

{
       string strdata;//存储节点上的字符串
       vector<node*> Child;//存储该节点的字节点的地址
       int flag;//辅助标志位,用0和1表示该节点是否有子节点
       int breakpoint;//副主变量,当该节点需要分裂时,用于记录分裂点的位置
}*mynode;

class CSuffixTree

{
       private:
       string data,left;//data源字符串变量,在构造函数中初始化
                        //left用于记录每次搜索结束后,目标字符串中的剩余字符串
       public:
       mynode ST,point;//ST生成的后缀树的根节点
                        //point节点指针,搜索时指向搜索节点的父节点,搜索结束时根据搜索//结果指向要操作的节点

       CSuffixTree(string str);
       int Search(string str);
       void CreatTree();
       void Show(mynode ST);
       void PrintNode(mynode p, int c, vector<bool>& isend);
       ~CSuffixTree(void);
};


CSuffixTree::CSuffixTree(string str)
//构造函数,初始化data变量和ST,point指针并产个根节
//点的第一个子节点,ST的flag置1
{

              data=str;
              ST=(mynode) new node;
              point=(mynode) new node;
              point->strdata = data[0];
              point->flag = 0;
              ST->Child.push_back(point);
              ST->flag=1;
}

CSuffixTree::~CSuffixTree(void)//析构函数
{

}


int CSuffixTree::Search(string str)
//返回1则在指针point所指向的节点的strdata后追加
//left字符串
//返回2则生成point所指向的节点的子节点,子节点
//的strdata值为left字符串
//返回0则donothing
//返回-1则分裂节点将分裂点写入point指针所指向的
//节点的breakpoint,并将目标字符串的剩余字符串写
//入left
{
       stack<char> s;
       int i,n=0;
       mynode child;
       char target;
       point=ST;//初始搜索位置为根
       child=NULL;
       for (i=(str.length()-1);i>=0;i--)//将目标字符串str压栈
              s.push(str[i]);
       while(!s.empty())//直到搜索完str串
       {
              for (i=0;i<=(point->Child.size()-1);i++)//寻找point所指向的节点下与str首字母相同的子节点
                    if (point->Child[i]->strdata[0]==s.top())
                     {
                            child=point->Child[i];//child指针指向与str具有相同首字母的节点
                            break;
                     }
        if (child==NULL)//父节点point下没有首字母相同的子节点

              {                          //将str中剩余的字符串保存在left中

                     left.erase(left.begin(),left.end());
                     while(!s.empty())
                     {
                            left.insert(left.end(),s.top());
                            s.pop();
                     }
                     return (2);
              }
              target=s.top();//
              s.pop();
              if (1)
              {
                     for (i=0;i<=(child->strdata.length()-1);i++)// child节点下的每个字符与str中的字符顺序比较
                     {
                            if (child->strdata[i]==target)
                            {
                                   if (!s.empty())
                                   {
                                          target=s.top();
                                          s.pop();
                                          continue;
                                   }
                                   else return(0);//若str中的字符串先于strdata中的字符串完成比较,则

//说明该字符串已经包含在树中
                            }
                            else //比较中出现不同,需要分裂节点
                            {
                                   point=child;//point指向要分裂的节点
                                   left.erase(left.begin(),left.end());//将str中剩余的字符串写入left
                                   s.push(target);
                                   while(!s.empty())
                                   {
                                          left.insert(left.end(),s.top());
                                          s.pop();
                                   }
                                   point->breakpoint=i;//写入父节点point的分裂点
                                   return (-1);//分裂节点
                            }
                     }
                     point=child;//走出循环则进行下一个节点的搜索
                     if (!point->flag)//判断刚刚搜索的是否为叶节点,若是则停止搜索
                     {
                            left.erase(left.begin(),left.end());
                            s.push(target);
                            while(!s.empty())
                            {
                                   left.insert(left.end(),s.top());
                                   s.pop();
                            }
                            return (1);
                     }
                     s.push(target);
                     child=NULL;
              }
       }
       //字符串str搜索完成,仍没有到达叶节点,返回0
       return(0);
}

void CSuffixTree::CreatTree()
{
              int i,j,n,h,ic,jc;
              string temp;
              string tempuse;
              mynode cnode;
              for (i=1;i <= (data.length()-1);i++)//调用两层循环,产生目标字符串每一个前缀的所有后缀
                     for (j=0;j <= i;j++)
                     {
                            temp.erase(temp.begin(),temp.end());
                            ic=i;
                            jc=j;
                            for (;jc<=ic;jc++)
                                   temp.insert(temp.end(),data[jc]);
                            n=Search(temp);//调用Search函数搜索生成的字符串
                            switch (n)
                            {
                            case (-1)://分裂节点,父分裂点为point->breakpoint
                                   tempuse=point->strdata;
                                   cnode=(mynode) new node;
                                   if (point->Child.size() != 0)
                                          cnode->Child=point->Child;
                                   cnode->flag=point->flag;
                                   point->Child.erase(point->Child.begin(),point->Child.end());
                                   point->strdata.erase(point->strdata.begin(),point->strdata.end());
                                   for (h=0;h<(point->breakpoint);h++)

                                          point->strdata.insert(point->strdata.end(),tempuse[h]);
                                   for (h=(point->breakpoint);h<tempuse.length();h++)
                                          cnode->strdata.insert(cnode->strdata.end(),tempuse[h]);
                                   point->Child.push_back(cnode);
                                   cnode=(mynode) new node;
                                   cnode->strdata=left;
                                   cnode->flag=0;
                                   point->Child.push_back(cnode);
                                   point->flag=1;
                                   break;

                            case (0)://do nothing
                                   break;

                            case (1)://在叶节点point处追加left字符串
                                   point->strdata=point->strdata+left;
                                   break;

                            case (2)://在父节点point下添加子节点cnode
                                   cnode=(mynode) new node;
                                   cnode->strdata=left;
                                   cnode->flag=0;
                                   point->Child.push_back(cnode);
                                   point->flag=1;
                                   break;
                            }
                     }
       }

void CSuffixTree::Show(mynode m_pSTreeRoot)
{
       vector<bool> bIsEnd;
       bIsEnd.push_back(0);
       cout<<"Root"<<endl;
       for(int i=0;i<(int)m_pSTreeRoot->Child.size();i++)
       {
              if(i==(int)m_pSTreeRoot->Child.size()-1)
                     bIsEnd[0]=1;
              PrintNode(m_pSTreeRoot->Child[i],1,bIsEnd);
       }
       cout<<endl;
}

void CSuffixTree::PrintNode(mynode p, int c, vector<bool>& isend)
{

       for(int j=0;j<c;j++)
       {
              if(isend[j]==0)
                     if(j!=c-1)cout<<"│";
                            else cout<<"├";
              else
                     if(j!=c-1)cout<<"  ";
                            else cout<<"└";
              if(j!=c-1)cout<<"  ";
                     else cout<<"─";
       }

       cout<<" "<<p->strdata;
       //if(p->Child.size()==0)cout<<" ("<<p->nIndex<<")";
       cout<<endl;
       for(int i=0;i<(int)p->Child.size();i++)
       {
              if(isend.size()==c)isend.push_back(0);
              else isend[c]=0;
              if(i==(int)p->Child.size()-1)
                     if(isend.size()==c)isend.push_back(1);
                     else isend[c]=1;
              PrintNode(p->Child[i],c+1,isend);
       }
}


void main()
{
       string a;
       cout<<"Please input a string:";
       cin>>a;//通过输入获得目标字符串a
       CSuffixTree mytree(a);//产生CsuffixTree类的实例mytree
       mytree.CreatTree();//调用CreatTree方法创建一棵后缀树
       mytree.Show(mytree.ST);//调用Show方法输出生成的后缀树
}




 
威士忌 @ 2006-07-14 21:01

今天06.07.14号,又是一个值得记住的日子
台风“碧丽思”来了,好大啊,不适合出行
现在是晚上21:03,不适合开QQ
因为你又让我伤心了

不知道这次又和以前一样吗
我很希望只是像从前
像从前一样的你
只是想让我对你紧张一下而已
而这次,我感到你不像从前那样了
我有些害怕,猜不透你在想什么
就像那风一样
不知几时会停下

和你一起有时会累,有时会感到辛苦
却从没想过放弃
脑海里都是快乐的记忆

从前的我像风
不曾为谁停留
喜欢上你的我像云
开始考虑是否该驻足
爱上你的我像雨
即使可能没了自己
我也情愿湮灭在你的怀抱里
想和你永远在一起的我像水
留在你的心田
为你灌溉

是否你真的听见了,看见了
我在这里
希望你能蓦然回首
我依然在灯火阑珊处....




 
威士忌 @ 2006-07-12 21:55

Linkin Park--现在美国顶尖摇滚乐团,HEAVY METAL+RAP风格,听得很爽,很有爆炸力。
一听这名字就有为自己的目标拼搏的冲动~~
怒吼出来吧,追求属于自己的Somewhere I Belong !!!

--------------------------------
When this began  
I had nothing to say  
And I'd get lost in the nothingness inside of me  
I was confused  
And I let it all out to find /that I'm  
Not the only person with these things in mind  
Inside of me  
But all the vacancy the words revealed  
Is the only real thing that I've got left to feel  
Nothing to lose  
Just stuck/hollow and alone  
And the fault is my own  
And the fault is my own  
I want to heal  
I want to feel  
What I thought was never real  
I want to let go of the pain I've held so long  
[Erase all the pain 'til it's gone] I want to heal  
I want to feel  
Like I'm close to something real  
I want to find something i've wanted all along  
Somewhere I belong  
And I've got nothing to say  
I can't believe I didn't fall right down on my face  
I was confused  
Looking everywhere/only to find that it's  
Not the way I had imagined it all in my mind  
So what am I  
What do I have but negativity  
'Cause I can't justify the  
Way everyone is looking at me  
Nothing to lose  
Nothing to gain/hollow and alone  
And the fault is my own  
The fault is my own  
I will never know  
Myself until I do this on my own  
And I will never feel  
Anything else until my wounds are healed  
I will never be  
Anything 'til I break away from me  
And I will break away  
I'll find myself today  
I want to heal  
I want to feel like I'm  
Somewhere i belong  




 
威士忌 @ 2006-07-09 22:14

暑假都已经过了一个多星期了
生活还是没有步入正轨
每天都有事没事的耽搁了正事
外加这几天运气也特背
看来是该好好地自我检讨下了



 
威士忌 @ 2006-07-05 19:06

When You Believe 
                     Mariah Carey&Whitney Houston

<<埃及王子>>的主题曲,中文名是《当你相信时
玛利亚凯瑞和惠特尼休斯顿一起唱的
每次听到这首歌,就给人一种生命的力量
不管前路多渺茫,When You Belive....

---------------------------------------

Many nights we've prayed
With no proof anyone could hear
In our hearts a hopeful song
We barely understood
Now we are not afraid
Although we know there's much to fear
We were moving the mountains long
Before we knew we could
There can be miracles when you believe
Though hope is frail, it's hard to kill
Who knows what miracles you can achieve
When you believe
Somehow you will
You will when you believe
And this time of fear
When prayer so often proves in vain
Hope is like the summer birds
To swiftly flown away
Now I'm standing here
My heart so full I can't explain
Seeking faith and speaking words
I never thought I'd say
There can be miracles when you believe
Though hope is frail, it's hard to kill
Who knows what miracles you can achieve
When you believe
Somehow you will
You will when you believe
 

They don't know this answer when you ask them
And it's easy to give in to your fear
But When you fly as high past your pain
You can see your way through the rain
More of us still receive your advice
Says nothing's there we need
There can be miracles when you believe
Though hope is frail, it's hard to kill
Who knows what miracles you can achieve
When you believe
Somehow you will
Now you will
You will when you believe
You will when you believe
Just believe
Just believe
You will when you believe




 
威士忌 @ 2006-07-05 14:35

软件行业是一个智慧集中型行业,人才极度珍贵“。程序员走光”、死活招不到合适人选的情况,在许多企业中并不鲜见。
程序员真的走光了吗?
从调查数据和我自己的经验来看,不是程序员数量少,而是他们中的相当部分基础薄弱、经验欠缺,不足以直接进入第一线开发岗位。
21岁到25岁的,占总数的55%,即有超过一半的程序员,入行时间在三年以下。
在普遍缺乏良好培训机制和职业生涯规划的职业生存环境中,他们很难在三年内迅速成长为骨干开发人员。

不大于20 岁  5%
21-25 岁  55%
26-30 岁  31%
31-35 岁  7%
大于35 岁  2%
图4: 开发人员年龄分布

26到30岁人员,占总数的31%,这些人是企业开发的中坚力量。他们中的一部分人,成功转型为技术管理人员,另外一部分却开始为未来担忧:难道做一辈子开发?目前尚令人满意的收入(月收入达5000元以上占52%)和职位(资深工程师、项目经理、CTO),将来会不会发生变化?这些都是他们担心的因素。
中国程序员分布较为集中,主要在华北(26.2%)、华东(25.9%)、华南(21.9%)和华中(9.4%)地区,多在中小型(500人以下的占总数71%)民营企业(47.9%)工作。
他们中的大部分(55%)仍然从事编码工作,仅有10%转型成为项目经理。
令人高兴的是,单元测试、迭代开发的普及率,相比去年有了极大提高,但自动化测试工具使用比率偏低(30%),尚有提升空间。
软件开发生命周期管理,逐渐得到认同和重视,IBM Rational 和Borland棋先一着,较早认识到需求管理工具重要性,也在市场上获得相当份额(RequisitePro和CaliberRM分别占51%和30%);
建模工具领域 Visio、RationalRose/XDE和Power Designer分居三甲。

其它
RequisitePro
51%
CaliberRM
30%
图4: 需求管理工具份额比

从CSDN网站帖子和新闻访问量可以看出,IT人才类话题最受程序员关注。
今年我们连续做了数期在线聊天,请IBM、微软、BEA等大企业相关负责人谈人才问题。
包括微软亚洲工程院副院长张益肇博士在内的嘉宾,都不约而同提到,企业最希望要基础扎实、学习能力强、沟通能力强的人才。
我自己也经常面试程序员,见面两个问题:1、什么是虚方法,为什么需要虚方法?2、你能脱离IDE开发工具写代码和编译吗?已经足以涮掉一半以上应聘者。
对于准备入行或刚入行的新手,打好基础是正道。




 
威士忌 @ 2006-07-05 14:35

1995年,Internet Explorer第一个版本随Windows 95推出。其时距WWW发明不过5年,距TCP/IP协议进入ARPANET刚好15年。
到IE 3.0的时候,原来不可一世的 NetScape 已是一败涂地。
如今Google风头正劲,微软似乎又陷入被动,尴尬一如当年面临Netscape高歌猛进时。
Firefox浏览器面世后,占有率迅速攀升,至10%左右遭遇瓶颈。这本是意料中事,因为Firefox犯了一个错误,这个错误也让 Unix系统无法占领 PC客户端,那就是:geek/hacker思想。
在我的电脑上,Firefox频频出错,有人告诉我可以修改某个配置文件,因为Firefox默认不是按照最稳定的选项来设置。如果你不指望只是想上网打拖拉机的妈妈去编译BSD内核,最好也别指望普通人懂得改配置文件。
如果Firefox只是想做一个好浏览器,那它会败得更彻底。
照Mozilla一贯的表现来看,到后面不会有它什么事儿。真正的决战将发生在Google和微软之间。
在布局上,Google走Web OS路线,微软走OS Web路线。
此话怎讲?Google正在努力使Web成为一个计算平台,规避与微软在操作系统层面的正面冲突,而微软则希望将Web更深地绑到操作系统上,大家都在扬长避短。
Firefox不幸成为两片面包中间的牛肉饼,难逃被压扁的命运。
这场决战胜负未卜,Google和微软都在比速度,看谁的计算平台更早出来、更快占领PC桌面。明年Vista面世,将是微软的一张大牌。
如果届时Google没有好牌可打,至少微软会赢第一局。
Web本身作为一个运行平台先天不足,正因如此,扩展Web运算能力成为厂商争夺的焦点。
但是别忘了,Web也是历史产物,且终将消灭。Web 2.0是一个过渡,未来的网络计算平台,会基于P2P架构。只有两类网站有存活意义,一类是社区网站,另一类是服务网站。