锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美精品丝袜久久久中文字幕,亚洲国产另类久久久精品小说,久久久精品国产sm调教网站http://www.shnenglu.com/Darren/category/12419.htmlC++ 鍙婄畻娉?/description>zh-cnFri, 27 Nov 2009 14:01:46 GMTFri, 27 Nov 2009 14:01:46 GMT60Pku 3169 Layouthttp://www.shnenglu.com/Darren/archive/2009/07/20/90649.htmlDarrenDarrenMon, 20 Jul 2009 11:55:00 GMThttp://www.shnenglu.com/Darren/archive/2009/07/20/90649.htmlhttp://www.shnenglu.com/Darren/comments/90649.htmlhttp://www.shnenglu.com/Darren/archive/2009/07/20/90649.html#Feedback0http://www.shnenglu.com/Darren/comments/commentRss/90649.htmlhttp://www.shnenglu.com/Darren/services/trackbacks/90649.html #include聽 < stdio.h >
#include聽
< stdlib.h >
#include聽
< string .h >

#define 聽N聽1005
#define 聽inf聽1<<29

struct 聽Edge{
聽聽聽聽
int 聽u,聽v,聽d;
聽聽聽聽Edge(聽
int 聽a = 0 ,聽 int 聽b = 0 ,聽 int 聽c = 0 聽):
聽聽聽聽聽聽聽聽u(a),聽v(b),聽d(c)聽{}
};

int 聽n,聽ml,聽md,聽s = 0 ;
Edge聽聽ege[
20010 ];
int 聽dist[N];

int 聽bell_man(){
聽聽聽聽
for (聽 int 聽i = 1 ;聽i <= 聽n;聽 ++ i聽)聽dist[i] = 聽inf;
聽聽聽聽dist[
1 ] = 0 ;
聽聽聽聽
聽聽聽聽
int 聽flag = 0 ;
聽聽聽聽
for (聽 int 聽i = 1 ;聽i <= 聽n;聽 ++ i聽){
聽聽聽聽聽聽聽聽flag
= 0 ;
聽聽聽聽聽聽聽聽
for (聽 int 聽j = 0 ;聽j < 聽s;聽 ++ j聽){
聽聽聽聽聽聽聽聽聽聽聽聽
int 聽u = 聽ege[j].u,聽v = 聽ege[j].v,聽w = 聽ege[j].d;
聽聽聽聽聽聽聽聽聽聽聽聽
if (聽dist[u] + 聽w < 聽dist[v]聽)聽dist[v] = 聽dist[u] + 聽w,聽flag = 1 ;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
if (聽 ! flag聽)聽 break ;
聽聽聽聽}
聽聽聽聽
if (聽flag聽)聽 return - 1 ;
聽聽聽聽
else if (聽dist[n] == 聽inf聽)聽 return - 2 ;
聽聽聽聽
else return 聽dist[n];
}

int 聽main(){
聽聽聽聽scanf(
" %d%d%d " , & n, & ml, & md聽);
聽聽聽聽
int 聽u,聽v,聽d;
聽聽聽聽
while (聽ml -- 聽){
聽聽聽聽聽聽聽聽scanf(
" %d%d%d " , & u, & v, & d聽);
聽聽聽聽聽聽聽聽ege[s
++ ] = 聽Edge(聽u,聽v,聽d聽);
聽聽聽聽}
聽聽聽聽
while (聽md -- 聽){
聽聽聽聽聽聽聽聽scanf(
" %d%d%d " , & u, & v, & d聽);
聽聽聽聽聽聽聽聽ege[s
++ ] = 聽Edge(聽v,聽u,聽 - d聽);
聽聽聽聽}
聽聽聽聽printf(
" %d\n " ,聽bell_man()聽);

聽聽聽聽
return 0 ;
}


Darren 2009-07-20 19:55 鍙戣〃璇勮
]]>
Pku 1986 Distance Querieshttp://www.shnenglu.com/Darren/archive/2009/07/20/90590.htmlDarrenDarrenMon, 20 Jul 2009 02:56:00 GMThttp://www.shnenglu.com/Darren/archive/2009/07/20/90590.htmlhttp://www.shnenglu.com/Darren/comments/90590.htmlhttp://www.shnenglu.com/Darren/archive/2009/07/20/90590.html#Feedback0http://www.shnenglu.com/Darren/comments/commentRss/90590.htmlhttp://www.shnenglu.com/Darren/services/trackbacks/90590.html #include聽 < iostream >
#include聽
< vector >

using namespace 聽std;

#define 聽N聽40010
typedef聽pair
< int , int > 聽PAIR;

int 聽m,聽n;
vector
< PAIR > 聽query[N],聽map[N];

int 聽uset[N] = 聽{ 0 },聽acs[N],聽flag[N] = 聽{ 0 },聽dis[N] = 聽{ 0 },聽ans[N],聽visite[N] = { 0 };

int 聽find(聽 int 聽x聽){
聽聽聽聽
while (聽x != 聽uset[x]聽)聽x = 聽uset[x];
聽聽聽聽
return 聽x;聽}

void 聽join(聽 int 聽x,聽 int 聽y聽){聽聽uset[聽find(x)聽] = 聽uset[聽find(y)聽];聽}

void 聽dfs(聽 int 聽u,聽 int 聽d聽){
聽聽聽聽uset[u]
= 聽u;聽acs[u] = 聽u;聽dis[u] = 聽d;聽visite[u] = 1 ;
聽聽聽聽
for (聽size_t聽i = 0 ;聽i < 聽map[u].size();聽 ++ i聽){
聽聽聽聽聽聽聽聽
int 聽v = 聽map[u][i].first,聽w = 聽map[u][i].second;
聽聽聽聽聽聽聽聽
if (聽 ! visite[v]聽){
聽聽聽聽聽聽聽聽聽聽聽聽dfs(聽v,聽d
+ 聽w聽);
聽聽聽聽聽聽聽聽聽聽聽聽join(聽u,聽v聽);聽acs[聽find(u)聽]
= 聽u;聽聽}
聽聽聽聽}
聽聽聽聽
聽聽聽聽flag[u]
= 1 ;
聽聽聽聽
for (聽size_t聽i = 0 ;聽i < 聽query[u].size();聽 ++ i聽){
聽聽聽聽聽聽聽聽
int 聽v = 聽query[u][i].first,聽w = 聽query[u][i].second;
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
if (聽flag[v]聽)聽ans[w] = 聽dis[u] + 聽dis[v] - 2 * 聽dis[聽acs[聽find(v)聽]聽];
聽聽聽聽}聽聽聽聽
}

int 聽main(){
聽聽聽聽
int 聽u,聽v,聽d;
聽聽聽聽
char 聽s[ 10 ];
聽聽聽聽
聽聽聽聽scanf(
" %d%d " , & n, & m);
聽聽聽聽
while (聽m -- 聽){
聽聽聽聽聽聽聽聽scanf(
" %d%d%d%s " , & u, & v, & d,s聽);
聽聽聽聽聽聽聽聽map[u].push_back(聽PAIR(v,d)聽);
聽聽聽聽聽聽聽聽map[v].push_back(聽PAIR(u,d)聽);
聽聽聽聽}
聽聽聽聽
聽聽聽聽scanf(
" %d " , & m聽);
聽聽聽聽
for (聽 int 聽i = 1 ;聽i <= 聽m;聽 ++ i聽){
聽聽聽聽聽聽聽聽scanf(
" %d%d " , & u, & v聽);
聽聽聽聽聽聽聽聽query[u].push_back(聽PAIR(v,i)聽);
聽聽聽聽聽聽聽聽query[v].push_back(聽PAIR(u,i)聽);
聽聽聽聽}
聽聽聽聽memset(聽flag,聽
0 ,聽 sizeof (flag)聽);
聽聽聽聽memset(聽visite,聽
0 ,聽 sizeof (visite)聽);
聽聽聽聽
聽聽聽聽dfs(聽
1 ,聽 0 聽);聽
聽聽聽聽
for (聽 int 聽i = 1 ;聽i <= 聽m;聽 ++ i聽)聽printf( " %d\n " ,聽ans[i]聽);
聽聽聽聽
聽聽聽聽
return 0 ;
}


Darren 2009-07-20 10:56 鍙戣〃璇勮
]]>
Pku 1258 Agri-Nethttp://www.shnenglu.com/Darren/archive/2008/11/05/66039.htmlDarrenDarrenWed, 05 Nov 2008 08:30:00 GMThttp://www.shnenglu.com/Darren/archive/2008/11/05/66039.htmlhttp://www.shnenglu.com/Darren/comments/66039.htmlhttp://www.shnenglu.com/Darren/archive/2008/11/05/66039.html#Feedback0http://www.shnenglu.com/Darren/comments/commentRss/66039.htmlhttp://www.shnenglu.com/Darren/services/trackbacks/66039.html #include聽 < stdio.h >
#include聽
< string .h >
#include聽
< limits.h >

#define 聽聽N聽聽110

int 聽聽n,result;
int 聽聽map[N][N];
bool 聽visite[N];
int 聽聽dis[N];

void 聽聽Prim()
{
聽聽聽聽memset(聽visite,聽
false ,聽 sizeof (visite)聽);
聽聽聽聽visite[
0 ] = true ;聽聽result = 0 ;
聽聽聽聽
聽聽聽聽
for (聽 int 聽i = 0 ;聽i < 聽n;聽 ++ i聽)聽聽dis[i] = 聽map[ 0 ][i];
聽聽聽聽
聽聽聽聽
for (聽 int 聽i = 1 ;聽i < 聽n;聽 ++ i聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
int 聽min = 聽INT_MAX,聽k;
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
for (聽 int 聽j = 0 ;聽j < 聽n;聽 ++ j聽)
聽聽聽聽聽聽聽聽
if (聽 ! visite[j]聽 && 聽dis[j] < 聽min聽)聽min = 聽dis[j],聽k = 聽j;
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽visite[k]
= true ;聽聽result += 聽dis[k];
聽聽聽聽聽聽聽聽
for (聽 int 聽j = 0 ;聽j < 聽n;聽 ++ j聽)
聽聽聽聽聽聽聽聽
if (聽 ! visite[j]聽 && 聽map[k][j] > 0 && 聽map[k][j] < 聽dis[j]聽)聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽dis[j]
= 聽map[k][j];
聽聽聽聽}

}


int 聽main()
{
聽聽聽聽
while (聽scanf( " %d " , & n) != 聽EOF聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
for (聽 int 聽i = 0 ;聽i < 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽聽聽聽
for (聽 int 聽j = 0 ;聽j < 聽n;聽 ++ j聽)
聽聽聽聽聽聽聽聽聽聽聽scanf(
" %d " ,聽 & map[i][j]聽);
聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽Prim();
聽聽聽聽聽聽聽聽printf(
" %d\n " ,聽result聽);
聽聽聽聽}

聽聽聽聽
聽聽聽聽
return 0 ;
}

聽聽聽聽


Darren 2008-11-05 16:30 鍙戣〃璇勮
]]>
Pku 1047 Round and Round We Gohttp://www.shnenglu.com/Darren/archive/2008/10/30/65580.htmlDarrenDarrenThu, 30 Oct 2008 13:16:00 GMThttp://www.shnenglu.com/Darren/archive/2008/10/30/65580.htmlhttp://www.shnenglu.com/Darren/comments/65580.htmlhttp://www.shnenglu.com/Darren/archive/2008/10/30/65580.html#Feedback0http://www.shnenglu.com/Darren/comments/commentRss/65580.htmlhttp://www.shnenglu.com/Darren/services/trackbacks/65580.html #include聽 < stdio.h >
#include聽
< stdlib.h >
#include聽
< string .h >

int 聽聽聽visite[ 15 ];
char 聽聽str[ 100 ];
int 聽聽聽d[ 100 ];
int 聽聽聽len;

bool 聽multi(聽 int 聽n聽)
{
聽聽聽聽
int 聽t[ 100 ];
聽聽聽聽
int 聽v[ 15 ];
聽聽聽聽
for (聽 int 聽i = 0 ;聽i < 聽len;聽 ++ i聽)聽t[i] = 聽d[i];聽聽
聽聽聽聽
for (聽 int 聽i = 0 ;聽i < 15 ;聽 ++ i聽聽)聽v[i] = 聽visite[i];
聽聽聽聽
聽聽聽聽
for (聽 int 聽i = 0 ;聽i < 聽len;聽 ++ i聽)
聽聽聽聽t[i]
*= 聽n;
聽聽聽聽
聽聽聽聽
for (聽 int 聽i = 聽len - 1 ;聽i > 0 ;聽i -- 聽)
聽聽聽聽{
聽聽聽聽聽聽聽聽t[i
- 1 ] += 聽t[i] / 10 ;
聽聽聽聽聽聽聽聽t[i]
%= 10 ;
聽聽聽聽}
聽聽聽聽
聽聽聽聽
if (聽t[ 0 ] >= 10 聽)聽 return false ;
聽聽聽聽
for (聽 int 聽i = 0 ;聽i < 聽len;聽 ++ i聽)聽聽 if (聽 -- v[聽t[i]聽] < 0 聽)聽 return false ;
聽聽聽聽
聽聽聽聽
return true ;
}

bool 聽isok()
{
聽聽聽聽
for (聽 int 聽i = 2 ;聽i <= 聽len;聽 ++ i聽)
聽聽聽聽
if (聽 ! multi(聽i聽)聽)聽 return false ;
聽聽聽聽
聽聽聽聽
return true ;
}

int 聽main()
{
聽聽聽聽
while (聽scanf( " %s " ,str) != 聽EOF聽)
聽聽聽聽{
聽聽聽聽聽聽聽聽len
= 聽strlen(聽str聽);聽聽
聽聽聽聽聽聽聽聽memset(聽visite,聽
0 ,聽 sizeof (visite)聽);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
for (聽 int 聽i = 0 ;聽i < 聽len;聽 ++ i聽)聽{聽d[i] = 聽str[i] - ' 0 ' ;聽visite[聽d[i]聽] ++ ;聽}
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
if (聽isok()聽)聽printf( " %s聽is聽cyclic\n " ,聽str聽);
聽聽聽聽聽聽聽聽
else 聽聽聽聽聽聽聽聽聽printf( " %s聽is聽not聽cyclic\n " ,聽str聽);
聽聽聽聽}
聽聽聽聽
聽聽聽聽
return 0 ;
}


Darren 2008-10-30 21:16 鍙戣〃璇勮
]]>
Pku 1089 Intervalshttp://www.shnenglu.com/Darren/archive/2008/10/29/65487.htmlDarrenDarrenWed, 29 Oct 2008 15:01:00 GMThttp://www.shnenglu.com/Darren/archive/2008/10/29/65487.htmlhttp://www.shnenglu.com/Darren/comments/65487.htmlhttp://www.shnenglu.com/Darren/archive/2008/10/29/65487.html#Feedback0http://www.shnenglu.com/Darren/comments/commentRss/65487.htmlhttp://www.shnenglu.com/Darren/services/trackbacks/65487.html #include聽 < stdio.h >
#include聽
< stdlib.h >

#define 聽N聽50001

struct 聽Node
{
聽聽聽聽
int 聽a,聽b;
}
;

Node聽d[N];
int 聽聽n;

int 聽cmp(聽 const void * 聽a,聽 const void * 聽b聽)
{
聽聽聽聽Node
* 聽ta = 聽(Node * )a;
聽聽聽聽Node
* 聽tb = 聽(Node * )b;
聽聽聽聽
聽聽聽聽
if (聽ta -> a == 聽tb -> a聽)聽 return 聽ta -> b - 聽tb -> b;
聽聽聽聽
聽聽聽聽
return 聽ta -> a - 聽tb -> a;
}


int 聽main()
{
聽聽聽聽scanf(
" %d " ,聽 & n);
聽聽聽聽
聽聽聽聽
for (聽 int 聽i = 0 ;聽i < 聽n;聽 ++ i聽)聽聽scanf( " %d%d " ,聽 & d[i].a,聽 & d[i].b聽);
聽聽聽聽qsort(聽d,聽n,聽
sizeof (聽d[ 0 ]聽),聽cmp聽);
聽聽聽聽
聽聽聽聽
int 聽min = 聽d[ 0 ].a,聽max = 聽d[ 0 ].b;
聽聽聽聽
for (聽 int 聽i = 1 ;聽i < 聽n;聽 ++ i聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
if (聽d[i].a > 聽max聽)
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽printf(
" %d聽%d\n " ,聽min,聽max聽);
聽聽聽聽聽聽聽聽聽聽聽聽min
= 聽d[i].a,聽max = 聽d[i].b;
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
else if (聽d[i].b > 聽max聽)聽max = 聽d[i].b;
聽聽聽聽}

聽聽聽聽printf(
" %d聽%d\n " ,聽min,聽max聽);
聽聽聽聽
聽聽聽聽
return 0 ;
}



Darren 2008-10-29 23:01 鍙戣〃璇勮
]]>
Pku 1062 鏄傝吹鐨勮仒紺?/title><link>http://www.shnenglu.com/Darren/archive/2008/10/29/65475.html</link><dc:creator>Darren</dc:creator><author>Darren</author><pubDate>Wed, 29 Oct 2008 13:01:00 GMT</pubDate><guid>http://www.shnenglu.com/Darren/archive/2008/10/29/65475.html</guid><wfw:comment>http://www.shnenglu.com/Darren/comments/65475.html</wfw:comment><comments>http://www.shnenglu.com/Darren/archive/2008/10/29/65475.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Darren/comments/commentRss/65475.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Darren/services/trackbacks/65475.html</trackback:ping><description><![CDATA[ <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000">#include聽</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">stdio.h</span> <span style="COLOR: #000000">></span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" />#include聽</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">limits.h</span> <span style="COLOR: #000000">></span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" />#include聽</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">stdlib.h</span> <span style="COLOR: #000000">></span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" />#include聽</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">math.h</span> <span style="COLOR: #000000">></span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" />#include聽</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #0000ff">string</span> <span style="COLOR: #000000">.h</span> <span style="COLOR: #000000">></span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">#define</span> <span style="COLOR: #000000">聽N聽110</span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽graph[N][N];<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽rank[N];<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽value[N];<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽m,聽n,聽len;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #0000ff">bool</span> <span style="COLOR: #000000">聽聽findrank(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽t聽)<br /><img id="Codehighlighter1_197_277_Open_Image" onclick="this.style.display='none'; Codehighlighter1_197_277_Open_Text.style.display='none'; Codehighlighter1_197_277_Closed_Image.style.display='inline'; Codehighlighter1_197_277_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_197_277_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_197_277_Closed_Text.style.display='none'; Codehighlighter1_197_277_Open_Image.style.display='inline'; Codehighlighter1_197_277_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span> <span id="Codehighlighter1_197_277_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_197_277_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽i</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">;聽i</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">聽t;聽</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">i聽)<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">(聽value[i]</span> <span style="COLOR: #000000">==</span> <span style="COLOR: #000000">聽t聽)聽</span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">true</span> <span style="COLOR: #000000">;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">false</span> <span style="COLOR: #000000">;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽dis(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽Rank聽)<br /><img id="Codehighlighter1_300_1042_Open_Image" onclick="this.style.display='none'; Codehighlighter1_300_1042_Open_Text.style.display='none'; Codehighlighter1_300_1042_Closed_Image.style.display='inline'; Codehighlighter1_300_1042_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_300_1042_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_300_1042_Closed_Text.style.display='none'; Codehighlighter1_300_1042_Open_Image.style.display='inline'; Codehighlighter1_300_1042_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span> <span id="Codehighlighter1_300_1042_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_300_1042_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">bool</span> <span style="COLOR: #000000">聽visite[N];<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽聽result[N];<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽rank[</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽Rank;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽i</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">;聽i</span> <span style="COLOR: #000000"><=</span> <span style="COLOR: #000000">聽n;聽</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">i聽)聽<br /><img id="Codehighlighter1_385_546_Open_Image" onclick="this.style.display='none'; Codehighlighter1_385_546_Open_Text.style.display='none'; Codehighlighter1_385_546_Closed_Image.style.display='inline'; Codehighlighter1_385_546_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_385_546_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_385_546_Closed_Text.style.display='none'; Codehighlighter1_385_546_Open_Image.style.display='inline'; Codehighlighter1_385_546_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽</span> <span id="Codehighlighter1_385_546_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_385_546_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽t</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽Rank</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">聽rank[i];<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /><img id="Codehighlighter1_437_482_Open_Image" onclick="this.style.display='none'; Codehighlighter1_437_482_Open_Text.style.display='none'; Codehighlighter1_437_482_Closed_Image.style.display='inline'; Codehighlighter1_437_482_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_437_482_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_437_482_Closed_Text.style.display='none'; Codehighlighter1_437_482_Open_Image.style.display='inline'; Codehighlighter1_437_482_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">(聽t</span> <span style="COLOR: #000000"><=</span> <span style="COLOR: #000000">聽m聽</span> <span style="COLOR: #000000">&&</span> <span style="COLOR: #000000">聽t</span> <span style="COLOR: #000000">>=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">聽)聽</span> <span id="Codehighlighter1_437_482_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_437_482_Open_Text"> <span style="COLOR: #000000">{聽visite[i]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">false</span> <span style="COLOR: #000000">;聽聽result[i]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽graph[</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">][i];聽}</span> </span> <span style="COLOR: #000000"> <br /> <img id="Codehighlighter1_507_543_Open_Image" onclick="this.style.display='none'; Codehighlighter1_507_543_Open_Text.style.display='none'; Codehighlighter1_507_543_Closed_Image.style.display='inline'; Codehighlighter1_507_543_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_507_543_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_507_543_Closed_Text.style.display='none'; Codehighlighter1_507_543_Open_Image.style.display='inline'; Codehighlighter1_507_543_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">else</span> <span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span> <span id="Codehighlighter1_507_543_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_507_543_Open_Text"> <span style="COLOR: #000000">{聽visite[i]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">true</span> <span style="COLOR: #000000">;聽聽聽result[i]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">;聽}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽visite[</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">true</span> <span style="COLOR: #000000">;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽t</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">;聽t</span> <span style="COLOR: #000000"><=</span> <span style="COLOR: #000000">聽n;聽</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">t聽)<br /><img id="Codehighlighter1_598_1019_Open_Image" onclick="this.style.display='none'; Codehighlighter1_598_1019_Open_Text.style.display='none'; Codehighlighter1_598_1019_Closed_Image.style.display='inline'; Codehighlighter1_598_1019_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_598_1019_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_598_1019_Closed_Text.style.display='none'; Codehighlighter1_598_1019_Open_Image.style.display='inline'; Codehighlighter1_598_1019_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽</span> <span id="Codehighlighter1_598_1019_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_598_1019_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽聽min</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽INT_MAX;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽聽k</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽i</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">;聽i</span> <span style="COLOR: #000000"><=</span> <span style="COLOR: #000000">聽n;聽</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">i聽)<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #000000">!</span> <span style="COLOR: #000000">visite[i]聽</span> <span style="COLOR: #000000">&&</span> <span style="COLOR: #000000">聽result[i]</span> <span style="COLOR: #000000">>=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">&&</span> <span style="COLOR: #000000">聽result[i]</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">聽min聽聽)<br /><img id="Codehighlighter1_731_763_Open_Image" onclick="this.style.display='none'; Codehighlighter1_731_763_Open_Text.style.display='none'; Codehighlighter1_731_763_Closed_Image.style.display='inline'; Codehighlighter1_731_763_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_731_763_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_731_763_Closed_Text.style.display='none'; Codehighlighter1_731_763_Open_Image.style.display='inline'; Codehighlighter1_731_763_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span id="Codehighlighter1_731_763_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_731_763_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽min</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽result[i];<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽k</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽i;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">(聽k</span> <span style="COLOR: #000000">==</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">聽)聽</span> <span style="COLOR: #0000ff">break</span> <span style="COLOR: #000000">;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽visite[k]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">true</span> <span style="COLOR: #000000">;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽i</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">;聽i</span> <span style="COLOR: #000000"><=</span> <span style="COLOR: #000000">聽n;聽</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">i聽)<br /><img id="Codehighlighter1_841_1015_Open_Image" onclick="this.style.display='none'; Codehighlighter1_841_1015_Open_Text.style.display='none'; Codehighlighter1_841_1015_Closed_Image.style.display='inline'; Codehighlighter1_841_1015_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_841_1015_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_841_1015_Closed_Text.style.display='none'; Codehighlighter1_841_1015_Open_Image.style.display='inline'; Codehighlighter1_841_1015_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span id="Codehighlighter1_841_1015_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_841_1015_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #000000">!</span> <span style="COLOR: #000000">visite[i]聽</span> <span style="COLOR: #000000">&&</span> <span style="COLOR: #000000">聽聽graph[k][i]</span> <span style="COLOR: #000000">>=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">&&</span> <span style="COLOR: #000000">聽result[k]</span> <span style="COLOR: #000000">>=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #000000">&&</span> <span style="COLOR: #000000">聽(聽result[k]</span> <span style="COLOR: #000000">+</span> <span style="COLOR: #000000">聽graph[k][i]</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">聽result[i]聽</span> <span style="COLOR: #000000">||</span> <span style="COLOR: #000000">聽result[i]</span> <span style="COLOR: #000000">==</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">聽)聽)<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽result[i]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽result[k]</span> <span style="COLOR: #000000">+</span> <span style="COLOR: #000000">聽graph[k][i];<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #000000">聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000">聽result[</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">];<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽main()<br /><img id="Codehighlighter1_1056_1574_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1056_1574_Open_Text.style.display='none'; Codehighlighter1_1056_1574_Closed_Image.style.display='inline'; Codehighlighter1_1056_1574_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1056_1574_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1056_1574_Closed_Text.style.display='none'; Codehighlighter1_1056_1574_Open_Image.style.display='inline'; Codehighlighter1_1056_1574_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span> <span id="Codehighlighter1_1056_1574_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_1056_1574_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽scanf(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">%d%d</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">,聽</span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000">m,聽</span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000">n);<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽len</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽memset(聽graph,聽</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">,聽</span> <span style="COLOR: #0000ff">sizeof</span> <span style="COLOR: #000000">(</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">)</span> <span style="COLOR: #000000">*</span> <span style="COLOR: #000000">N</span> <span style="COLOR: #000000">*</span> <span style="COLOR: #000000">N聽);<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽i</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">;聽i</span> <span style="COLOR: #000000"><=</span> <span style="COLOR: #000000">聽n;聽</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">i聽)<br /><img id="Codehighlighter1_1164_1405_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1164_1405_Open_Text.style.display='none'; Codehighlighter1_1164_1405_Closed_Image.style.display='inline'; Codehighlighter1_1164_1405_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1164_1405_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1164_1405_Closed_Text.style.display='none'; Codehighlighter1_1164_1405_Open_Image.style.display='inline'; Codehighlighter1_1164_1405_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽</span> <span id="Codehighlighter1_1164_1405_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_1164_1405_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽va,聽ra,聽nn;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽scanf(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">%d%d%d</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">,聽</span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000">va,聽</span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000">ra,聽</span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000">nn聽);<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽graph[</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">][i]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽va;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽rank[i]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽ra;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #000000">!</span> <span style="COLOR: #000000">findrank(聽ra聽)聽)聽value[len</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽ra;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽j</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">;聽j</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">聽nn;聽</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">j聽)<br /><img id="Codehighlighter1_1336_1402_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1336_1402_Open_Text.style.display='none'; Codehighlighter1_1336_1402_Closed_Image.style.display='inline'; Codehighlighter1_1336_1402_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1336_1402_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1336_1402_Closed_Text.style.display='none'; Codehighlighter1_1336_1402_Open_Image.style.display='inline'; Codehighlighter1_1336_1402_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span id="Codehighlighter1_1336_1402_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_1336_1402_Open_Text"> <span style="COLOR: #000000">{<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽a,聽b;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽scanf(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">%d%d</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">,聽</span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000">a,聽</span> <span style="COLOR: #000000">&</span> <span style="COLOR: #000000">b);<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽graph[a][i]</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽b;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽}</span> </span> <span style="COLOR: #000000">聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽min</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽INT_MAX;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">for</span> <span style="COLOR: #000000">(聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽i</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">;聽i</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">聽len;聽</span> <span style="COLOR: #000000">++</span> <span style="COLOR: #000000">i聽)<br /><img id="Codehighlighter1_1461_1532_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1461_1532_Open_Text.style.display='none'; Codehighlighter1_1461_1532_Closed_Image.style.display='inline'; Codehighlighter1_1461_1532_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1461_1532_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1461_1532_Closed_Text.style.display='none'; Codehighlighter1_1461_1532_Open_Image.style.display='inline'; Codehighlighter1_1461_1532_Open_Text.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span id="Codehighlighter1_1461_1532_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://www.shnenglu.com/images/dot.gif" /> </span> <span id="Codehighlighter1_1461_1532_Open_Text"> <span style="COLOR: #000000">{聽聽聽聽聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">int</span> <span style="COLOR: #000000">聽t</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽dis(聽value[i]聽);<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">(聽t</span> <span style="COLOR: #000000"><</span> <span style="COLOR: #000000">聽min聽</span> <span style="COLOR: #000000">&&</span> <span style="COLOR: #000000">聽t</span> <span style="COLOR: #000000">!=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">-</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">聽)聽min</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽t;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽printf(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">%d\n</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">,聽min聽);<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">return</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">;<br /><img src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span> </span> <span style="COLOR: #000000"> <br /> <img src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align="top" /> </span> </div> <img src ="http://www.shnenglu.com/Darren/aggbug/65475.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Darren/" target="_blank">Darren</a> 2008-10-29 21:01 <a href="http://www.shnenglu.com/Darren/archive/2008/10/29/65475.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Pku 1094 Sorting It All Outhttp://www.shnenglu.com/Darren/archive/2008/10/03/63175.htmlDarrenDarrenThu, 02 Oct 2008 17:35:00 GMThttp://www.shnenglu.com/Darren/archive/2008/10/03/63175.htmlhttp://www.shnenglu.com/Darren/comments/63175.htmlhttp://www.shnenglu.com/Darren/archive/2008/10/03/63175.html#Feedback0http://www.shnenglu.com/Darren/comments/commentRss/63175.htmlhttp://www.shnenglu.com/Darren/services/trackbacks/63175.html #include聽 < iostream >
#include聽
< stack >
#include聽
< vector >

int 聽聽聽n,聽m;
int 聽聽聽degree[ 26 ];
int 聽聽聽data[ 26 ][ 26 ];
bool 聽聽exist[ 26 ];

std::vector
< char > 聽re;

int 聽length()
{
聽聽聽聽
int 聽num = 0 ;
聽聽聽聽
for 聽(聽 int 聽i = 0 ;聽i < 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽
if 聽(聽exist[i]聽)
聽聽聽聽聽聽聽聽聽聽聽聽num
++ ;

聽聽聽聽
return 聽num;
}


int 聽toplogicalsort()
{
聽聽聽聽std::stack
< char > 聽st;
聽聽聽聽
int * 聽d = new int [n];

聽聽聽聽re.clear聽();

聽聽聽聽
for 聽(聽 int 聽i = 0 ;聽i < 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽d[i]
= 聽degree[i];

聽聽聽聽
for 聽(聽 int 聽i = 0 ;聽i < 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽
if 聽(聽d[i] == 0 && 聽exist[i]聽)st.push(i);

聽聽聽聽
bool 聽ok = true ;
聽聽聽聽
while (聽 ! st.empty()聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
if 聽(聽( int )st.size聽() > 1 聽)聽聽ok = false ;

聽聽聽聽聽聽聽聽
int 聽t = 聽st.top聽();
聽聽聽聽聽聽聽聽st.pop();

聽聽聽聽聽聽聽聽re.push_back聽(聽t
+ ' A ' 聽);

聽聽聽聽聽聽聽聽
for 聽(聽 int 聽i = 0 ;聽i < 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽data[i][t] == 1 && 聽exist[i]聽)
聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽d[i]
-- ;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽d[i] == 0 聽)聽聽聽st.push聽(i);
聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽}


聽聽聽聽
int 聽len = 聽length();
聽聽聽聽
if 聽(聽( int )re.size聽() < 聽len聽)聽 return 2 ;聽聽聽 // 聽exit聽circle

聽聽聽聽
if 聽(聽 ! ok聽)聽 return 0 ;
聽聽聽聽
if 聽(聽( int )re.size聽() == 聽n聽)聽聽 return 1 ;

聽聽聽聽
return 0 ;
}


int 聽main()
{
聽聽聽聽
while (聽scanf( " %d%d " , & n, & m),聽m + 聽n != 0 聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽memset(聽degree,聽
0 ,聽 sizeof (degree)聽);
聽聽聽聽聽聽聽聽memset(聽data,聽聽聽
0 ,聽 sizeof (data聽聽)聽);
聽聽聽聽聽聽聽聽memset(聽exist,聽聽
false ,聽 sizeof (exist)聽);

聽聽聽聽聽聽聽聽
bool 聽isok = true ;
聽聽聽聽聽聽聽聽
bool 聽determin = false ;
聽聽聽聽聽聽聽聽getchar();

聽聽聽聽聽聽聽聽
for 聽(聽 int 聽i = 1 ;聽i <= 聽m;聽 ++ 聽i聽)
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽
char 聽a,聽b;

聽聽聽聽聽聽聽聽聽聽聽聽a
= 聽getchar();
聽聽聽聽聽聽聽聽聽聽聽聽getchar();
聽聽聽聽聽聽聽聽聽聽聽聽b
= 聽getchar();
聽聽聽聽聽聽聽聽聽聽聽聽getchar();

聽聽聽聽聽聽聽聽聽聽聽聽exist[a
- ' A ' ] = true ;
聽聽聽聽聽聽聽聽聽聽聽聽exist[b
- ' A ' ] = true ;

聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽聽 ! determin聽 && 聽isok聽 && 聽(data[a - ' A ' ][b - ' A ' ] == 1 || 聽a == 聽b)聽聽)
聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽isok
= false ;

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(
" Inconsistency聽found聽after聽%d聽relations.\n " ,聽i);
聽聽聽聽聽聽聽聽聽聽聽聽}


聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽data[b - ' A ' ][a - ' A ' ] == 0 聽)聽degree[b - ' A ' ] ++ ;
聽聽聽聽聽聽聽聽聽聽聽聽data[b
- ' A ' ][a - ' A ' ] = 1 ;

聽聽聽聽聽聽聽聽聽聽聽聽
int 聽type;
聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽 ! determin聽 && 聽isok聽 && 聽(type = 聽toplogicalsort())聽聽)
聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽type == 1 聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽determin
= true ;聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(
" Sorted聽sequence聽determined聽after聽%d聽relations:聽 " ,聽i聽);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for 聽(聽size_t聽x = 0 ;聽x < 聽re.size聽();聽 ++ x聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(
" %c " ,聽re[x]聽);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(
" .\n " );
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
else if 聽(聽type == 2 聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽isok
= false ;

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(
" Inconsistency聽found聽after聽%d聽relations.\n " ,聽i);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
if 聽(聽 ! determin聽 && 聽isok聽)聽printf( " Sorted聽sequence聽cannot聽be聽determined.\n " );
聽聽聽聽}


聽聽聽聽
return 0 ;
}


Darren 2008-10-03 01:35 鍙戣〃璇勮
]]>
pku 1797 Heavy Transportationhttp://www.shnenglu.com/Darren/archive/2008/10/02/63160.htmlDarrenDarrenThu, 02 Oct 2008 09:39:00 GMThttp://www.shnenglu.com/Darren/archive/2008/10/02/63160.htmlhttp://www.shnenglu.com/Darren/comments/63160.htmlhttp://www.shnenglu.com/Darren/archive/2008/10/02/63160.html#Feedback0http://www.shnenglu.com/Darren/comments/commentRss/63160.htmlhttp://www.shnenglu.com/Darren/services/trackbacks/63160.html #include聽 < iostream >
#include聽
< algorithm >
#include聽
< limits >

int 聽聽n,m;
int 聽聽graph[ 1001 ][ 1001 ];
bool 聽visite[ 1001 ];
int 聽聽result[ 1001 ];

void 聽shortpath()
{
聽聽聽聽memset(聽visite,聽
false ,聽 sizeof (visite)聽);
聽聽聽聽memset(聽result,聽
0 ,聽 sizeof (result)聽);

聽聽聽聽visite[
1 ] = true ;

聽聽聽聽
for 聽(聽 int 聽i = 1 ;聽i <= 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽聽聽聽聽result[i]
= 聽graph[ 1 ][i];

聽聽聽聽
for 聽(聽 int 聽i = 1 ;聽i < 聽n;聽 ++ i聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
int 聽max = 0 ;
聽聽聽聽聽聽聽聽
int 聽k = - 1 ;

聽聽聽聽聽聽聽聽
for 聽(聽 int 聽j = 1 ;聽j <= 聽n;聽 ++ j聽)
聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽 ! visite[j]聽 && 聽result[j] > 聽max聽)
聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽max
= 聽result[j];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽k
= 聽j;
聽聽聽聽聽聽聽聽聽聽聽聽}


聽聽聽聽聽聽聽聽visite[k]
= true ;
聽聽聽聽聽聽聽聽
for 聽(聽 int 聽j = 1 ;聽j <= 聽n;聽 ++ j聽)
聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽 ! visite[j]聽 && 聽graph[k][j] > 0 聽聽 && 聽result[j] < 聽std::min(聽result[k],聽graph[k][j]聽)聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽result[j]
= 聽std::min聽(聽result[k],聽graph[k][j]);
聽聽聽聽}


}


int 聽main()
{
聽聽聽聽
int 聽test;
聽聽聽聽scanf(
" %d " , & test);

聽聽聽聽
for 聽(聽 int 聽t = 1 ;聽t <= 聽test;聽 ++ t聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽scanf(
" %d%d " , & n, & m);
聽聽聽聽聽聽聽聽memset(聽graph,聽
0 ,聽 sizeof (graph)聽);

聽聽聽聽聽聽聽聽
for 聽(聽 int 聽i = 0 ;聽i < 聽m;聽 ++ i聽)
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽
int 聽x,聽y,d;
聽聽聽聽聽聽聽聽聽聽聽聽scanf(
" %d%d%d " , & x, & y, & d);

聽聽聽聽聽聽聽聽聽聽聽聽graph[x][y]
= 聽d;
聽聽聽聽聽聽聽聽聽聽聽聽graph[y][x]
= 聽d;
聽聽聽聽聽聽聽聽}


聽聽聽聽聽聽聽聽shortpath();
聽聽聽聽聽聽聽聽printf(
" Scenario聽#%d:\n " ,聽t聽);
聽聽聽聽聽聽聽聽printf(
" %d\n " ,聽result[n]聽);
聽聽聽聽聽聽聽聽printf(
" \n " );
聽聽聽聽}


聽聽聽聽
return 0 ;
}





Darren 2008-10-02 17:39 鍙戣〃璇勮
]]>
pku 2253 Froggerhttp://www.shnenglu.com/Darren/archive/2008/10/02/63152.htmlDarrenDarrenThu, 02 Oct 2008 07:24:00 GMThttp://www.shnenglu.com/Darren/archive/2008/10/02/63152.htmlhttp://www.shnenglu.com/Darren/comments/63152.htmlhttp://www.shnenglu.com/Darren/archive/2008/10/02/63152.html#Feedback0http://www.shnenglu.com/Darren/comments/commentRss/63152.htmlhttp://www.shnenglu.com/Darren/services/trackbacks/63152.html #include聽 < iostream >
#include聽
< cmath >
#include聽
< limits >

struct 聽Point
{
聽聽聽聽
int 聽x,y;
}
;

double 聽graph[ 201 ][ 201 ];
Point聽聽聽data[
201 ];
int 聽聽聽聽聽n;
bool 聽聽聽聽visite[ 201 ];
double 聽聽result[ 201 ];

double 聽Distance(聽Point & 聽a,聽Point & 聽b聽)
{
聽聽聽聽
return 聽sqrt(聽( double )(聽(a.x - 聽b.x) * 聽(a.x - 聽b.x聽) + 聽(a.y - 聽b.y聽) * 聽(a.y - 聽b.y聽)聽)聽);
}


void 聽shortpath(聽 int 聽t聽)
{
聽聽聽聽
for 聽(聽 int 聽i = 1 ;聽i <= 聽n;聽 ++ i聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽visite[i]
= false ;
聽聽聽聽聽聽聽聽result[i]
= 0.0 ;
聽聽聽聽}


聽聽聽聽
for 聽(聽 int 聽i = 1 ;聽i <= 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽result[i]
= 聽graph[t][i];

聽聽聽聽visite[t]
= true ;
聽聽聽聽
for 聽(聽 int 聽i = 1 ;聽i <= 聽n - 1 ;聽 ++ i聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
double 聽min = 聽std::numeric_limits < double > ::max();

聽聽聽聽聽聽聽聽
int 聽k = - 1 ;
聽聽聽聽聽聽聽聽
for 聽(聽 int 聽j = 1 ;聽j <= 聽n;聽 ++ j聽)
聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽 ! visite[j]聽 && 聽result[j] < 聽min聽)
聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽min
= 聽result[j];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽k
= 聽j;
聽聽聽聽聽聽聽聽聽聽聽聽}


聽聽聽聽聽聽聽聽visite[k]
= true ;
聽聽聽聽聽聽聽聽
for 聽(聽 int 聽j = 1 ;聽j <= 聽n;聽 ++ j聽)
聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽 ! visite[j]聽 && 聽std::max(聽graph[k][j],聽result[k]聽) < 聽result[j]聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽result[j]
= 聽std::max(聽graph[k][j],聽result[k]聽);
聽聽聽聽}

}


int 聽main()
{
聽聽聽聽
int 聽num = 1 ;
聽聽聽聽
while (聽scanf( " %d " , & n),聽n != 0 聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
for 聽(聽 int 聽i = 1 ;聽i <= 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽聽聽聽聽scanf(
" %d%d " ,聽 & data[i].x,聽 & data[i].y聽);

聽聽聽聽聽聽聽聽
for 聽(聽 int 聽i = 1 ;聽i <= 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽聽聽聽聽
for 聽(聽 int 聽j = 1 ;聽j <= 聽n;聽 ++ j聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽graph[i][j]
= 聽Distance(聽data[i],聽data[j]聽);

聽聽聽聽聽聽聽聽shortpath(
1 );
聽聽聽聽聽聽聽聽printf(
" Scenario聽#%d\n " ,聽num ++ 聽);
聽聽聽聽聽聽聽聽printf(
" Frog聽Distance聽=聽%.3lf\n " ,聽result[ 2 ]聽);
聽聽聽聽聽聽聽聽printf(
" \n " );
聽聽聽聽}


聽聽聽聽
return 0 ;
}


Darren 2008-10-02 15:24 鍙戣〃璇勮
]]>
PKU 1018 Communication Systemhttp://www.shnenglu.com/Darren/archive/2008/10/01/63140.htmlDarrenDarrenWed, 01 Oct 2008 14:06:00 GMThttp://www.shnenglu.com/Darren/archive/2008/10/01/63140.htmlhttp://www.shnenglu.com/Darren/comments/63140.htmlhttp://www.shnenglu.com/Darren/archive/2008/10/01/63140.html#Feedback2http://www.shnenglu.com/Darren/comments/commentRss/63140.htmlhttp://www.shnenglu.com/Darren/services/trackbacks/63140.html

#include聽 < iostream >
#include聽
< set >
#include聽
< limits >

using namespace 聽std;

struct 聽Node
{
聽聽聽聽
int 聽broad,聽price;
聽聽聽聽Node()
{}
聽聽聽聽Node(
int & a, int & b)
聽聽聽聽聽聽聽聽:broad(a),price(b)
聽聽聽聽
{}
}
;

Node聽data[
100 ][ 100 ];
int 聽聽length[ 100 ];


int 聽main()
{
聽聽聽聽
int 聽test;
聽聽聽聽scanf(
" %d " , & test);

聽聽聽聽
while (聽test -- 聽)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
int 聽n;
聽聽聽聽聽聽聽聽
set < int > 聽br;

聽聽聽聽聽聽聽聽scanf(
" %d " , & n);

聽聽聽聽聽聽聽聽
for 聽(聽 int 聽i = 0 ;聽i < 聽n;聽 ++ i聽)
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽
int 聽d,x,y;
聽聽聽聽聽聽聽聽聽聽聽聽scanf(
" %d " , & d);

聽聽聽聽聽聽聽聽聽聽聽聽length[i]
= 聽d;
聽聽聽聽聽聽聽聽聽聽聽聽
for 聽(聽 int 聽j = 0 ;聽j < 聽d;聽 ++ j聽)
聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽scanf(
" %d%d " , & x, & y);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽data[i][j]
= 聽Node(x,y);

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽br.insert(x);聽聽聽聽
// 聽聽聽Save聽all聽broad聽,聽use聽set聽to聽avoid聽repeating
聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽}


聽聽聽聽聽聽聽聽
set < int > ::iterator聽pos;
聽聽聽聽聽聽聽聽
double 聽max = 聽numeric_limits < double > ::min();
聽聽聽聽聽聽聽聽
for 聽(聽pos = 聽br.begin聽();聽pos != 聽br.end聽();聽 ++ pos聽)聽聽聽 // 聽聽聽for聽every聽broad
聽聽聽聽聽聽聽聽 {
聽聽聽聽聽聽聽聽聽聽聽聽
int 聽聽聽t = * pos;
聽聽聽聽聽聽聽聽聽聽聽聽
int 聽聽聽total = 0 ;
聽聽聽聽聽聽聽聽聽聽聽聽
bool 聽聽isok = false ;

聽聽聽聽聽聽聽聽聽聽聽聽
for 聽(聽 int 聽i = 0 ;聽i < 聽n;聽 ++ i聽)聽聽聽 // 聽聽n聽devices
聽聽聽聽聽聽聽聽聽聽聽聽 {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int 聽M = 聽INT_MAX;

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for 聽(聽 int 聽j = 0 ;聽j < 聽length[i];聽 ++ j聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽data[i][j].broad >= 聽t聽 && 聽data[i][j].price < 聽M聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽M
= 聽data[i][j].price;聽聽聽聽聽聽 // 聽聽聽find聽聽the聽min聽price

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽M == 聽INT_MAX聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽isok
= true ;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
break ;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽total
+= 聽M;聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽}


聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽isok聽)聽 continue ;

聽聽聽聽聽聽聽聽聽聽聽聽
if 聽(聽( double )t / 聽( double )total > 聽max聽)聽max = 聽( double )t / 聽( double )total;聽聽聽 // 聽聽update
聽聽聽聽聽聽聽聽}


聽聽聽聽聽聽聽聽printf(
" %.3lf\n " ,聽max聽);
聽聽聽聽}


聽聽聽聽
return 0 ;
}


Darren 2008-10-01 22:06 鍙戣〃璇勮
]]>
国产精品美女久久久久久2018| 久久99九九国产免费看小说| 国产成人无码久久久精品一| 精品蜜臀久久久久99网站| 99久久国产主播综合精品| 久久综合久久伊人| 久久久久无码精品国产| 久久久人妻精品无码一区| 伊人久久综合无码成人网| 热久久这里只有精品| 亚洲精品美女久久久久99| 国产精品免费久久久久电影网| 东方aⅴ免费观看久久av| 9999国产精品欧美久久久久久| 狠狠色噜噜色狠狠狠综合久久| 久久精品国产秦先生| 日韩人妻无码精品久久免费一| 国产高清国内精品福利99久久| 久久无码人妻一区二区三区午夜| 欧美久久一区二区三区| 久久精品这里热有精品| 久久精品一本到99热免费| 久久国产精品免费一区| 狠狠色丁香婷婷久久综合不卡| 成人久久免费网站| 综合网日日天干夜夜久久 | 亚洲欧洲日产国码无码久久99| 国产一久久香蕉国产线看观看| 无码精品久久久久久人妻中字| 亚洲精品tv久久久久| 精品久久久久久无码人妻蜜桃| 91麻豆精品国产91久久久久久| 久久91精品国产91久久小草 | 国产精品久久影院| 三上悠亚久久精品| 亚洲国产精品无码成人片久久| 久久婷婷色香五月综合激情| 无码人妻久久一区二区三区蜜桃| 久久久久女教师免费一区| 久久国产精品二国产精品| 久久综合精品国产一区二区三区|