英语习语中的Bite

Bite这个词本来很简单,但是在实际运用中,可以活用的地方有很多。例如,在《绝望的主妇》第二季第二十集中,一次,Lynette在帮助上司Ed与妻子进行网络聊天时,他模仿Ed的口气暧昧地说: i will bite you good. (我会把你咬得全舒舒服服的.)

 http://ykyi.net

t Susan就像猫和老鼠一样,好像注定是天敌。Edie口中最尖酸的话好像都指向了susan,有一次,她脱口就骂Susan: You bitch! Susan总是要内敛一些,她没有直接骂Edie是bitch,但动动却表达了同样的意思。因为她迅速地回击说: Bite me ! 也就是说:你咬我吧。你能把我怎么样?

 

Bite me 是对对方的一种挑衅。

 

Bite 可以利用的场合远不止此。如果你早上起晚了,而上班时间马上又要到了,那么早点又不能不吃,你可能会随便吃一口面包,这样你可以说:I will take a bite of bread this time.

 

英语中,可以用go for a bite表示“出去吃饭”例如:

what’s up ? 干什么呢?

Well, i was wondering if you’d like to go for a bite. 嗯,我在想你是否想出去吃饭。

再如,有一句广告词上写着: save those leftovers and go out for bite on Friday.(星期五不吃剩菜,出去吃)

 http://ykyi.net

还有四个与bite有关的短语,值得一学。

All bark and No bite.  什么意思呢?中国的俗语里面也有类似的说话,即“叫唤的狗不咬人(Barking dogs seldom bite.)” All bark and No Bite的意思跟这个很相似,即“嘴上说说,实际上不会怎样””雷声大,雨点小。”例如: The new manager threatened to fire me but i know he won’t do it; he is all bark and no bite.

Bite off more than you can Chew.   什么意思呢? 这句短语有“贪多嚼不烂”的意思。例如:I thought I could finish this report within one month, but it looks like I have bitten off more than I can chew.

Bite your tongue.  什么意思呢?字面意思是说“咬住舌头”,意思是“控制住自己,忍着不要乱说话(hold your tongue)”例如: whenever that professor says something i don’t like, i have to bite my tongue.每当那位教授讲到我不喜欢的事情时,我总得忍着不说话。

Never bite the hand that feeds you. 什么意思呢?字面上理解:不要咬掉给自己喂饭的手。可引申为:不要忘恩负义。例如:we have been your best customers for years. How could u suddenly treat us so rudely? You should never bite the hand that feeds you.

Get over somebody

短语: get over 什么意思.

I know you’re trying to get over Morty, but this is not the way to do it.

我知道你在尽力忘了Morty,但是,这不是正确的作法。

在这里get over 的意思是”忘却”,它还有”结束;熬过;康复” 的意思。如果说 He finally got over his divorce,那就指他人离婚中恢复过来,不再为此事烦恼或煎熬了,已回到正常的生活中了。

Even though we have broken for such a long time, I still couldn’t get her over.

虽然我们已经分手很长时间了,可我还是忘不了她。

Get over除了当”忘记”讲,还有一个意思”克服,忍受”相当于over come.例如:

No matter what it takes, we must get over this difficulty.

It took me a long time to get over my flu.

老友记 里的对白:

Ross : so, r u gonna c him again?

Monica: Tomorrow night.

Rachel: Monica, what r u doing?

Chandler: well, she spent the last six months getting over him, and now she’s celebrating that by going on a date with him.(这样,她刚花了六个月时间努力忘记他,现在她以和他约会来庆祝这个胜利。)

A pillar of salt 什么意思. 盐柱子是什么意思. lot’s wife什么意思.

<绝望的主妇> 第二季第十一集中,Bree对Andrew和男友Justin在自家前院的暧昧行为提出了批评,没想到反遭讥讽:“Oh, and you didn't turn into a pillar of salt. Good for you。" 噢,还好,你没有变成盐柱子。

怎么会变成盐柱子呢?原来这个典故来自于圣经里的故事。

这个故事是这样的: 

当上帝开始摧毁罪恶之城所多玛和俄摩拉城时,他派出两位天使力劝善人罗德及其家人赶快离开,并警告他们在逃跑时千万不要往回看。但是罗德的妻子特别好奇,她想知道这座故乡城市到底会发生什么。在她回头看时,她变成了一个盐柱子。

所以英语中就有了Lot's Wife和a pillar of salt来指代"分好奇的人"。

另外    ykyi.net 还有两个关于salt的短语.

worth one's salt 是指称职,有能力,能胜任的意思。原因是盐曾作为工资支付手段,工资金salary也就是源于此。例如: That actor is not worth his salt. (那个演员不称职。)

rub salt in an old wound 表示"故意提及伤心地往事" 例如:

Do you remember that time you were giving a speech and you dropped your laptop computer?

Oh, please, let's not rub salt in old wounds.

英语习语中Dead的用法

绝望的主妇 第一季第13集中Lynette对Tom说的非常绝妙的一句话: I guess i just got so upset because —- oh, whatever, let’s not beat a dead horse, it’s over, Im sorry, good night. ( 想那事让我这么心烦就是因为—-哦,随他去吧,事已至此,也别白费口舌了,这件事到此为止,我很抱歉。晚安。)

zausiu’s blog http://ykyi.net

这句话中的beat a dead horse 这个表达非常形象,这里的beat也可用flog替换。大家想象一下,用鞋子抽打死马让它驰骋,就是再大的力也没有用。因此这个表达用来表示”徒劳,作无用功”或是指”对已摒 弃或认可的活动信念徒费精力”。英语中还有很多跟dead用关的用法。

老友记中Earl先生想自杀的原因之一就是他觉得自己从事一个dead-end job (没有前途的工作)。

dead-end 是美国俚语,意思是死胡同,与中文里穷途末路相似。

美国作家Sidney Kingsley于1935年创作现实主义作品Dead End<死巷>。小说反映美国纽约大城市贫民窟中青少年的生活,1937年被编成电影Dead End Kids《死巷小子》。之后dead-end kid就是“穷孩子,浑小子或没有出息的男人”的意思。

The City Hall is more often a dead end than a stepping-stone for improving one’s political careers. 在市政大厅里工作,对于一个需要政治前途的人来说,与其说是一块垫脚石,还不如说是一个死胡同。

zausiu’s blog: http://ykyi.net

再介绍一下dead in the water的意思。

Dead in the water 出自航海用语,原来是指在航行中船中发生故障而无法启动。失去动力的船 只只能随波逐流,就像死鱼漂浮在水面上。此语可以形容经济发展的停滞不前或不景气(stagnation)。比如:

The Swiss Bank’s plan to launder money skimmed from casinos was dead in the water. 瑞士银行企图为赌场得来的钱洗钱的计划泡了汤。

Dead Sea Scrools是什么意思呢?

Dead Sea Scrolls 也称Qumran Scrolls,直译为”死海古卷”,其常用的比喻意思是”千古之谜”。考古学家在西南亚希比特库姆兰等地的旷野洞察和犹太遗址中发现古代文献的与低沙草纸。据考证,这些古卷系犹太教艾逊尼派的藏书。但有部分古卷学者们仍然未能破解。于是人们常用死海古卷来表示人类文化历史上的谜团或至今尚未破译的秘密。

Dead-cat bounce是什么意思呢?

Dead-cat bounce是金融证券术语,比喻短暂的经济复苏,也可以比喻股票大幅下挫后的短线反弹。因为弹出的死猫没有活力,此语形象地描述了经济衰退和股票下跌产生的短暂抬头现象。

The dead-cat bounce has a domino effect on suppliers, factories, wholesalers and finally the consumers. 死猫反弹所产生的多米诺效应影响到供应商,工厂和批发商,最后还影响到消费者。

zausiu’s blog: http://ykyi.net

英语笔记

# in/out someone’s hair (不)给添乱,烦扰。
She was constantly in my hair, overseeing everything I did.

# Flip-flop 突然改变立场
Bree, could this flip-flop have something to do with the fact that Danielle is dating Mattew?

# Fresh as paint 容光焕发
You have been as fresh as paint over the last six months.
容易与fresh paint(油漆未干混淆)

# put an end to something

# The last straw 最后一根稻草

# Dead meat
If u keep slamming the door like this, u’re dead meat.

# There are rats in the basement that are hangingthemselves,couldn’t get any worse.

# Take it outside 出去单挑
Ross: Let’s, let’s take this outside? Who talks like that?
Big Bully: The guy that’s about to kick your ass talks like that.

# It never hurt to have a friend at court.
朝中有人好办事。

# Word is out all over town that … …已经满城风雨,全城尽知。
Word is out all over town that Bush may have affair with her.

# No one would say a word. 没人会反对。

# Church mouse
I’m well aware of your church mouse status.

# As busy as a bee; as true as a steel; as blind as a bat; as easy as a pie;
as graceful as a swan; as cool as a cucumber; as tamed as a hare; as mild as a dove; as bold as brass; as strong as a horse;

# bum out 气恼,抑郁
This blows my mind and i’m extremely bummed out. 中学生用语 and i’m extremely bummed out. 中学生用语

# what is done cannot be undone. 木已成舟。

# The goose is cooked 错误已造成.

# To err is man 人非圣贤,孰能无过。

# done deal 既成事实
It seems that it is a done deal already, rather than on conditional terms.
目前两方似乎已就此事达成协议,而不是在商议之中。

# nip in the bud 防患于未然,消灭于萌芽状态。

# path up 本意为修补,平息,拼揍。现在表示平息争吵,与break up意思相反。
Are you going to patch things up? 也可说成can’t u make up? make up还有个意思是化妆。

# put up with differences and peace will prevail.

# smoke the peace pipe 讲和
为什么smoke the peace pipe 是讲和的意思呢。因为以前北美的印第安人讲和的意思就在一起抽烟。
其它表示和好,讲和的短语还有。bury the hatchet(短柄小斧); hold out the olive branch伸出橄榄枝;cease hostilites 结束敌对;patch up a quarrel; forgive and forget; let bygones be bygones; beat swords into plowshares;

# The coast is clear. 平安无事了。
为什么The coast is clear表示平安无事呢?据说来自于海盗和偷渡客用语,你明白了吧!

# hit rock bottom 糟糕透顶
The economy has hit rock bottom.

# An octopus in Germany called Paul who has shot to stardom for his spot-on world cup predictions.

# Pull their hair out in frustration. 抓破头皮的郁闷呀。

# a yes-man 应声虫

# cut the apron string 剪断围裙带,摆脱依赖。
Hey, we all gotta cut the apron strings at some point.
到了这个份上,我们每个人都会剪断围裙带子的。
中文中的妻管严在英文里也是说成be tied to the apron strings of one’s wife.
Are you tied to the apron strings of your wife?

# An erect penis doesn’t have a conscious. 哈哈哈.译成色令智昏.
Even limp ones aren’t all that ethical. 不色智也昏.

# And then he got his zen look on his face and said. 一副参禅高僧样,意为要教训人。

# catch on (to something) 意识到,发觉,明白。
Jack’s always the last to catch on my joke.
You catch on fast. 聪明,一说就懂!

# dog days 三伏天

# put on weight 体重增加

# water under the bridge. 往事如烟。 绝望的主妇第二季第十二集中,Detective应约到饭店与Bree共进晚餐。席间,侦探先生委婉地为自己先前的行为道歉,Bree一笑而过,说道“That is all water under the bridge now”于是前嫌尽弃。

Unix网络编程 第13章 Daemon Processes and the inetd Superserver 笔记

# The syslogd daemon runs in an infinite loop that calls select, waiting for any one of its three descriptors to be readable. it reads the log message and does what the configuration file says to do with that message. If the daemon receives the SIGHUP signal, it rereads its configuration file. So, what are the three descriptors that the select system call is waiting for ?  1. A unix domain socket is created and bound to the pathname /var/run/log (/dev/log on some systems). 2. A udp socket is created and bound to port 514(the syslog service). 3. The pathname /devklog is opened. Any error messages from within the kernel appears as input on this device. Newer implementation disable the creation of the UDP socket, unless specified by the administrator, as allowing anyone to send UDP datagrams to this port opens the system up to denial-of-service attacks, where some one could fill up the filesystem.

# syslog函数的%m specification表示当前errno对应的error message.

# syslog函数的level和facility是为了配置如何处理各种log.配置文件是/etc/syslog.conf.

# logger命令可以产生log message。于是可以在shell脚本里使用logger.

# The purpose of the second fork is to guarantee that the daemon cannot automatically acquire a controlling terminal should it open a terminal device in the future. When a session leader without a controlling terminal opens a terminal device(that is not currently some other session's controlling terminal), the termianl becomes the controlling terminal of the session leader. But by calling fork a second time, we guarantee that the second child is no longer a session leader, so it cfannot acquire a controlling terminal. We must ignore SIGHUP because when the session leader terminates(the first child), all processes in the session(our second child)receive the SIGHUP signal.

# daemon通常把当前工作目录设为 / .如果不这样的话就会有可能使得不能unmount某些文件系统。 http://ykyi.net

# On linux, /var/log/message is where the system send all LOG_USER messages after connecting from the same machine(e.g. localhost). Page370.

# 早期的Unix系统,早于4.3BSD.有很多服务像ftp, telnet, rlogin, tftp等都是以daemon的形式运行。每一个都要在进程表里占一个位置(each one took a slot in the process table).但是每个daemon大多数时间都在睡眠状态。从4.3BSD开始引入了inetd.

# inetd的配置对于UDP的wait_flag必须是wait.因为UDP socket只有一个.如果不wait话,parent存在可能性先于child进程得到CPU。而udp socket缓冲中的数据还未来得及读出。这样,inetd的select又返回这个socket可读。wait_flag的wait的意思就是要wait到fork出的子进程结束。而tcp socket会在accept返回的时候给子进程一个connected socket.父进程可以立即得到CPU执行select判断listenning socket是否可读。  http://ykyi.net

# xinetd的配置采用每个服务一个配置文件.而inetd用一个monolithic configuration file.

# On a Berkely-derived kernel the timeout for a tcp connect is normally 75秒.

Unix网络编程 第十二章 IPv4 and IPv6 Interoperability

# Ethernet header contains a type fileld of 0x0800, which identifies the frame as an IPv4 frame.

# 若支持dual-stack的server既有IPv4又有IPv6。则IP层让server透明地既可处理IPv4又可处理IPv6.该server需要绑定到wildcard且未设置IPV6_V6ONLY socket option.

# UNP Page359 Figure 12.5 Summary of interoperability between IPv4 and IPv6 clients and servers.

# 尽可能用IPv6,  since an IPv6 client can still communicate with IPv4 servers, and vice versa.

Unix网络编程 第11章 Name and Address Conversions 笔记

# gethostbyname 和 gethostbyaddr 用来在 IPv4 地址和 hostname 之间转换. getservbyport 和 getservbyname 则是与服务相关。gethostbyname出错时不设errno而是设h_errno,并有hstrerror()函数。

# FQDN的全称是: Fully Qualified domain name. 技术上说必须以点号(period)终止.

# AAAA 被称为 "quad A" rcord, 给出了从hostname到Ipv6地址的映射。 PTR用来把IP地址到hostname.

# Entries in the DNS are known as Resource Records(RRs).

# 一个点分十进制(dotted-decimal)IPv4的地址前加 0::ffff:就是 IPv6的字符串形式。

# 与getpeername对应的函数不是gethostname而是getsockname.

# getaddrinfo函数的host参数指定为dotted-decimal IPv4或 IPv6 hex string,会使得只有IPv4或IPv6的addrinfo返回。

# 不给UDP套接字设置SO_REUSEADDR选项。We do not set the SO_REUSEADDR socket option for the UDP socket because this socket option can allow multiple sockets to bind the same UDP port on hosts that support multicasting. Since there is nothing like TCP's TIME_WAIT state for a UDP socket, there is no need to set this socket option when the server is started.

# 一般情况下,同端口的不同协议对应同样的服务。但也有例外。对于端口514,which is the rsh service with TCP, but the syslog service with UDP.

# gethostbyaddr的第一个参数是char* addr,而其实它并非指向一个char* 事实上指向in_addr结构体。

# getaddrinfo好复杂呀!hint的ai_flags设置了AI_CONONNAME成员得到host的canonical name.

# port 53 是domain service的端口号.

# 如果设置了IPV6_V6ONLY.那么一个来自ipv4 client的连接会被拒绝。

# POSIX says that specifying AF_UNSPEC will return addresses that can be used with any protocol family that can be used with the hostname and service name.

# POSIX specification also implies that if the AI_PASSIVE flag is specified without a hostname, then the IPv6 wildcard address(IN6ADDR_ANY_INIT or 0::0) should be returned as a sockaddr_in6 structure, along with the IPv4 wildcard address(INADDR_ANY or 0.0.0.0), which is returned as a sockaddr_in structure.

# An ipv6 server socket can handle both ipv4 and ipv6 on a dual-stack host. Refer to page319 in UNP for details.

Prof. Zixiang Xiong讲座 脏纸编码

作为主要兴趣在Linux方面的偏应用硕士,听了一个电信传输方面的学术讲座。所谓Dirty Paper Coding,我的理解是如果已知信道干扰,在发射机对发射信号预先减去该干扰,则发射信号经信道传输被接收机接收后,则信道干扰被自动抵消。很简单的Idea,但实际实施起来应该非常困难吧。Prof. Zixiang Xiong先介绍了他所工作的学校。呵。然后从Dirty-paper Coding的历史发展讲起。Instances of dirty paper coding include Costa precoding(1983) ,Tomlinson-Harashima precoding (1971) and the vector perturbation technique of Hochwald et al. (2005)。两位科学家GelfandPinsker开创了这个领域,到信息理论的实际设计准则如何应用到实践之中。Prof. Zixiang Xiong提出了两种有效的编码设计方法。理论回到实路,再介绍这两种编码设计方法在图形图象的数据隐藏,MIMO广播,抗噪预编码,无线网络传输协调方面的实际应用。Gaussian arbitrarily varying channel with a known interference signal at the encoder.

好复杂好深奥的数学变换。本次讲座的收获也就是让我一定程度上开拓了视野,接触到N多电信方面的术语。小波变换,脏纸编码,数字水印之类。术业有专功,我要专功我的Linux去嘞。。。

2021年6月13号更新。今年(2021年)我重学了信号与系统,数字信号~~对信号/电信方面的数学知识有了非常大的提高。

Sicily 1031 Campus 解题报告.

 

1 原题中文大意;
 
Sicily 1031 Campus实际上就是求一个图中给出两点的最短路径的问题。
 
2 算法思想及解题用到的主要数据结构;
 
用 dijkstra 算法求给定两点的最短路径.
 
按路径长度递增次序产生最短路径算法:   把V分成两组:   (1)S:已求出最短路径的顶点的集合   (2)V-S=T:尚未确定最短路径的顶点集合   将T中顶点按最短路径递增的次序加入到S中,   保证:(1)从源点V0到S中各顶点的最短路径长度都不大于   从V0到T中任何顶点的最短路径长度   (2)每个顶点对应一个距离值   S中顶点:从V0到此顶点的最短路径长度   T中顶点:从V0到此顶点的只包括S中顶点作中间   顶点的最短路径长度   依据:可以证明V0到T中顶点Vk的最短路径,或是从V0到Vk的   直接路径的权值;或是从V0经S中顶点到Vk的路径权值之和。
 
3  逐步求精算法描述
 
用邻接矩阵存放图.1. 初使时令 S={V0},T={其余顶点},T中顶点对应的距离值   若存在<V0,Vi>,d(V0,Vi)为<V0,Vi>弧上的权值   若不存在<V0,Vi>,d(V0,Vi)为∝   2. 从T中选取一个其距离值为最小的顶点W且不在S中,加入S   3. 对T中顶点的距离值进行修改:若加进W作中间顶点,从V0到Vi的   距离值比不加W的路径要短,则修改此距离值   重复上述步骤2、3,直到S中包含所有顶点,即S=T为止
 
3 程序注释清单 // 这份代码通不过sicily。有case错误。我实在找不到原因。
 
#include <map>

#include <vector>

#include <string>

#include <iostream>

#include <cstdlib>

#include <cstdio>

#include <cstring>

#include <cassert>



#define INFINITE 0x0FFFFFFF



// 这个类的函数几乎不做参数有效性的检查.

class graph_t

{

public:

// 构建一个 num x num 的邻接矩阵

graph_t(int num)

{

m_matrix = new int[num*num];

m_sunit = new bool[num];

m_spath_table = new int[num];

// memset(m_matrix, INFINITE, num*num);  // INFINITE 表示无穷远.

for ( int i = 0; i < num*num; i++ )

{

m_matrix[i] = INFINITE;

}

m_num = num;

}



// row,column 取 [0, m_num)

int& operator()(int row, int column)

{

return m_matrix[row * m_num + column];

}



// vtx_start, vtx_end 取 [vtx_start, vtx_end)

int shortestpath_dij(int vtx_start, int vtx_end)

{

init_dij(vtx_start);  // 初始化dijkstra算法需要的一些数据.



if ( vtx_end == vtx_start )

{

return this->operator()(vtx_start, vtx_end);

}



// 还剩 m_num - 1 个点.

for ( int i = 1; i < m_num; i++ )

{

// 找下一个最近的点.

int vtx = -1, min = INFINITE;

for ( int j = 0; j < m_num; j++ )

{

if ( m_sunit[j] )  // 这个点已经在已经求得最短路径的点的集合中了.

continue;



if ( m_spath_table[j] < min )

{

vtx = j;

min = m_spath_table[j];

}

}

// 已经没有连通的顶点了.

if ( vtx == -1 )

{

return -1;

}

m_sunit[vtx] = true;  // 把这个点加入集合中.



// 这个点是终点.  http://ykyi.net

if ( vtx == vtx_end )

{

return min;

}



// 因为找到了一个新的点加入了集合,更新最短路径表.

for ( int k = 0; k < m_num; k++ )

{

if ( m_sunit[k] )

continue;



if (  min + this->operator()(vtx, k) < m_spath_table[k] )

{

m_spath_table[k] = min + this->operator()(vtx, k);

}

}

}



assert(0); // it's not suppossed to reach here.

return -1;

}



~graph_t()

{

delete m_matrix;

delete m_sunit;

delete m_spath_table;

}



private:

void init_dij(int vtx_start)

{

memset(m_sunit, 0, m_num);   // 初始化为没有点加入这个已求得最短路径的终点集合.

for ( int i = 0; i < m_num; i++ )

{

m_spath_table[i] = this->operator()(vtx_start, i);

}

assert( 0 == m_spath_table[vtx_start] );

m_sunit[vtx_start] = true;

}



private:

int   m_num;

int*  m_matrix;  // 存邻接矩阵

bool* m_sunit;   // 在dijkstra计算过程中用来存某点是否已经是最短路径中的点.

int*  m_spath_table;  // 在dijkstra计算过程中存到某点是的最短路径是多少.

};





int main(int argc, char* argv[])

{

int case_count, path_count, weight, next_ava_vtx;

int vtx_start, vtx_end;

std::map<std::string, int> loc2vtx;  // 存地点字符串到图的顶点号的映射.

std::vector<int> spirit;

std::string line;



std::cin >> case_count;

for ( int i = 0; i < case_count; i++ )

{

loc2vtx.clear();

spirit.clear();

next_ava_vtx = 0;



std::cin >> path_count;

for ( int j = 0; j < path_count; j++ )

{

// 得到起点地址字符串.

std::cin >> line;

std::map<std::string, int>::iterator ite = loc2vtx.find(line);

if ( loc2vtx.end() != ite )

{

vtx_start = ite->second;

}

else

{

vtx_start = next_ava_vtx;

loc2vtx[line] = vtx_start;

next_ava_vtx++;

}

spirit.push_back(vtx_start);



// 得到终点地址字符串.

std::cin >> line;

ite = loc2vtx.find(line);

if ( loc2vtx.end() != ite )

{

vtx_end = ite->second;

}

else

{

vtx_end = next_ava_vtx;

loc2vtx[line] = vtx_end;

next_ava_vtx++;

}

spirit.push_back(vtx_end);



// 得到权重

std::cin >> weight;

spirit.push_back(weight);

}



// 至此 next_ava_vtx 中存放的实际上是邻接方阵的阶.

graph_t graph(next_ava_vtx);

for ( int i = 0; i < spirit.size()/3; i++ )

{

int x = spirit[3*i];

int y = spirit[3*i+1];

int w = spirit[3*i+2];

graph(x, y) = w;

graph(y, x) = w;

}

for ( int i = 0; i < next_ava_vtx; i++ )

{

graph(i, i) = 0;

}



std::cin >> line;

std::map<std::string, int>::iterator ite = loc2vtx.find(line);

if ( ite == loc2vtx.end() )

{

std::cout << "-1\n";

continue;

}

vtx_start = loc2vtx[line];



std::cin >> line;

ite = loc2vtx.find(line);

if ( ite == loc2vtx.end() )

{

std::cout << "-1\n";

continue;

}

vtx_end = loc2vtx[line];



if ( vtx_start == vtx_end )

{

std::cout << "0\n";

continue;

}



std::cout << graph.shortestpath_dij(vtx_start, vtx_end) << std::endl;

}



return 0;

}

 

 
4 对时间复杂度,空间复杂度方面的分析、估算。
 
时间复杂度和空间复杂度都是O(n*n).   http://ykyi.net
 
///////////// 原题
 
 
 
 
 
1031. Campus
 
 
 
 
 
Description
 
At present, Zhongshan University has 4 campuses with a total area of 6.17 square kilometers sitting respectively on both sides of the Pearl River or facing the South China Sea. The Guangzhou South Campus covers an area of 1.17 square kilometers, the North Campus covers an area of 0.39 square kilometers, the Guangzhou East Campus has an area of 1.13 square kilometers and the Zhuhai Campus covers an area of 3.48 square kilometers. All campuses have exuberance of green trees, abundance of lawns and beautiful sceneries, and are ideal for molding the temperaments, studying and doing research.
 
 
 
 
       Sometime, the professors and students have to go from one place to another place in one campus or between campuses. They want to find the shortest path between their source place S and target place T. Can you help them?
 
 
Input
 
The first line of the input is a positive integer C. C is the number of test cases followed. In each test case, the first line is a positive integer N (0<N<=100) that represents the number of roads. After that, N lines follow. The i-th(1<=i<=N) line contains two strings Si, Ti and one integer Di (0<=Di<=100). It means that there is a road whose length is Di between Si and Ti. Finally, there are two strings S and T, you have to find the shortest path between S and T. S, T, Si(1<=i<=N) and Ti(1<=i<=N) are all given in the following format: str_Campus.str_Place. str_Campus represents the name of the campus, and str_Place represents the place in str_Campus. str_Campus is "North", "South", "East" or "Zhuhai". str_Place is a string which has less than one hundred lowercase characters from "a-z". You can assume that there is at most one road directly between any two places.
 
Output
 
The output of the program should consist of C lines, one line for each test case. For each test case, the output is a single line containing one integer. If there is a path between S and T, output the length of the shortest path between them. Otherwise just output "-1" (without quotation mark). No redundant spaces are needed.