锘??xml version="1.0" encoding="utf-8" standalone="yes"?>免费无码国产欧美久久18,国内精品久久久久久99,99国产精品久久http://www.shnenglu.com/tianlearn-language/category/14785.htmlzh-cnMon, 27 Dec 2010 10:16:20 GMTMon, 27 Dec 2010 10:16:20 GMT60poj 1556 The Doors 鏈鐭礬 + 綰挎鍒や氦http://www.shnenglu.com/tianlearn-language/archive/2010/12/21/137143.html鐢板叺鐢板叺Tue, 21 Dec 2010 14:32:00 GMThttp://www.shnenglu.com/tianlearn-language/archive/2010/12/21/137143.htmlhttp://www.shnenglu.com/tianlearn-language/comments/137143.htmlhttp://www.shnenglu.com/tianlearn-language/archive/2010/12/21/137143.html#Feedback0http://www.shnenglu.com/tianlearn-language/comments/commentRss/137143.htmlhttp://www.shnenglu.com/tianlearn-language/services/trackbacks/137143.html
Source Code

Problem: 
1556  User: hehexiaobai 
Memory: 1092K  Time: 0MS 
Language: G
++  Result: Accepted 

Source Code 
#include
<iostream> // poj 1556
#include<cmath>
#include
<cstring>
using namespace std;
const int MAX = 205;
const double epsilon = 1e-10;
const double PI = acos(-1.0);

double min(double a, double b){ return a > b ? b : a; }
double max(double a, double b){ return a > b ? a : b; }

struct Point
{
    
double x, y;
    Point(){}
    Point(
double a, double b): x(a), y(b){}  

    Point 
operator + (Point b){
        
return Point(x + b.x, y + b.y);
    }

    Point 
operator - (Point b){
        
return Point(x - b.x, y - b.y);
    }

    
double operator * (Point b){
        
return x* b.y - y *b.x;
    }

    
bool operator == (Point b){
        
return (fabs(x - b.x)< epsilon) && (fabs(y - b.y) < epsilon);
    }
};

Point point[MAX];
double dis[MAX];
bool mp[MAX][MAX];
int nwalls, cntpoint; 

int direction(Point &p0, Point & p1, Point & p2)//鍒ゆ柇 p0p2鏄粠鍚戦噺p1p0緇昿0鐨勬棆杞柟鍚?/span>
{
    
double d = (p2 - p0) * (p1 - p0);
    
if(fabs(d) < epsilon) return 0;  //鍏辯嚎

    
if(d > 0.0return 1;  //欏烘椂閽?/span>
    
    
return -1;  //閫嗘椂閽?/span>
}

bool inBox(Point &pi, Point & pj, Point &pk)
{
    
return min(pi.x , pj.x) <= pk.x && pk.x <= max(pi.x, pj.x) &&
           min(pi.y , pj.y) 
<= pk.y && pk.y <= max(pi.y, pj.y);
}

bool segmentsIntersect(Point &p1, Point & p2, Point & p3, Point & p4)
{
    
int d1 = direction(p3, p4, p1),
        d2 
= direction(p3, p4, p2),
        d3 
= direction(p1, p2, p3),
        d4 
= direction(p1, p2, p4);

    
if(d1 * d2 < 0  && d3 * d4 <0)
        
return true;
    
    
if( d1 == 0 && inBox(p3, p4, p1))
        
return true;

    
if( d2 == 0 && inBox(p3, p4, p2))
        
return true;
    
    
if( d3 == 0 && inBox(p1, p2, p3))
        
return true;

    
if( d4 ==0 && inBox(p1, p2, p4))
        
return true;
    
    
return false;
}

void Dijstra()
{
    
int i,j ;
    
double d[MAX][MAX] ;    
    memset(d, 
0sizeof d);
    
for( i = 0; i < cntpoint; i ++)
        
for(j = i + 1; j < cntpoint; j++)
        {
            d[i][j] 
= d[j][i] = sqrt((point[i].x - point[j].x) * (point[i].x - point[j].x)
                                    
+ (point[i].y - point[j].y)*(point[i].y - point[j].y));
        }

    
const double INF = 1e40;
    
bool visit[MAX] = {0};

    
for( i = 0; i < cntpoint; i ++)
        dis[i] 
= INF;
    dis[
0= 0.0

    
for( i = 0; i <cntpoint; i ++)
    {
        
int index = -1;
        
double min = INF;
        
for(j = 0; j < cntpoint; j ++)
            
if(!visit[j] && fabs(dis[j] - min) > epsilon && dis[j] < min)
            {
                index 
= j;
                min 
= dis[j];
            }
        
        
if(index == -1)return;
        visit[index] 
= true;

        
for( j = 0; j < cntpoint; j ++)
            
if(!visit[j] && mp[index][j] == true && dis[j] > dis[index] + d[index][j])
                dis[j] 
= dis[index] + d[index][j];

    }
}

int main()
{
    
    
int i , j;
    
while(cin >> nwalls)
    {
        
if( nwalls == -1)break;
        
        memset(point, 
0sizeof point);
        memset(mp, 
0sizeof (mp));
        memset(dis, 
0sizeof dis);

        point[
0].x = 0.0;
        point[
0].y = 5.0;
        
        
double x, y1, y2, y3, y4;
        cntpoint 
= 1;
        
for(i = 1;i <= nwalls; i ++)
        {
            cin 
>> x >> y1 >> y2 >> y3 >> y4;

            point[cntpoint].x 
= x;
            point[cntpoint].y 
= 0.0;
            cntpoint 
++;

            point[cntpoint].x 
= x;
            point[cntpoint].y 
= y1;
            cntpoint 
++;
            
            point[cntpoint].x 
= x;
            point[cntpoint].y 
= y2;
            cntpoint 
++;
            
            point[cntpoint].x 
= x;
            point[cntpoint].y 
= y3;
            cntpoint 
++;

            point[cntpoint].x 
= x;
            point[cntpoint].y 
= y4;
            cntpoint 
++;

            point[cntpoint].x 
= x;
            point[cntpoint].y 
= 10.0;
            cntpoint 
++;
        }

        point[cntpoint].x 
= 10.0;
        point[cntpoint].y 
= 5.0;
        cntpoint 
++;
        
        
int tempi, tempj;
        
        
for( i = 0;  i < cntpoint ; i ++)
            
for(j = i + 1; j < cntpoint; j ++)
            {
                tempi 
= i / 6;
                
if( i % 6 != 0) tempi += 1;
                
                tempj 
= j/6;
                
if( j % 6 != 0) tempj += 1;

                
if(tempi == tempj)continue;
                
if(point[i].y < epsilon || point[j].y < epsilon || 
                    
10.0 - point[i].y < epsilon || 10.0 - point[j].y < epsilon)
                        
continue;
                
                
bool flag = true;
                
forint k = tempi + 1; k < tempj; k ++)
                {
                    
int t = (k - 1* 6;
                
//    if(i == 0 && j == 9){ cout << flag << endl; cout << t << endl; }
                    if(segmentsIntersect(point[i],point[j],point[t + 1],point[t + 2]))flag = false;
                    
if(segmentsIntersect(point[i],point[j],point[t + 3],point[t + 4]))flag = false;
                    
if(segmentsIntersect(point[i],point[j],point[t + 5],point[t + 6]))flag = false;
                    
                }
                
if(flag == true)
                {
                    mp[i][j] 
= mp[j][i] = true;
                }
            }
        
    
//    for( i = 0; i < cntpoint; i ++,cout << endl)
    
//        for(j = 0; j < cntpoint; j ++)
    
//            cout << mp[i][j] <<" ";
        
    

        Dijstra();    
    
//    for(i = 0; i < cntpoint ; i ++)
    
//        cout << i <<' '<<dis[i] << endl;

        cout.precision(
2);
        cout 
<<fixed << dis[cntpoint - 1<< endl;
    }

    
return 0;
}
//0.0 0.0  1.0  1.0   1.0 0.0 1.0 1.0
//0.0 0.0  1.0  1.0   0.0 1.0 1.0  0.0
//0.0 0.0  1.0  1.0   1.0 0.0 1.0 0.9




鐢板叺 2010-12-21 22:32 鍙戣〃璇勮
]]>
2021久久精品免费观看| 久久最新免费视频| 久久久久综合网久久| 久久免费视频观看| 亚洲精品午夜国产va久久| 亚洲中文久久精品无码| 国产精品毛片久久久久久久| 久久精品视屏| 国产产无码乱码精品久久鸭| 久久久久噜噜噜亚洲熟女综合| 久久人人添人人爽添人人片牛牛| 久久国产精品99国产精| 性高朝久久久久久久久久| 国产精品禁18久久久夂久| 久久久精品波多野结衣| 精品少妇人妻av无码久久| 欧洲性大片xxxxx久久久| 国产婷婷成人久久Av免费高清 | 久久人人爽人人爽人人爽 | 久久久精品国产| 国产精品成人无码久久久久久| 中文字幕乱码人妻无码久久| 久久99国产精品成人欧美| 九九精品99久久久香蕉| 亚洲午夜久久久久妓女影院 | 久久精品中文字幕第23页| 97久久久久人妻精品专区| 久久精品青青草原伊人| 久久青青草视频| 欧美伊人久久大香线蕉综合69| 狠狠色丁香婷婷综合久久来来去 | 久久久这里只有精品加勒比| 久久九九久精品国产| 久久99精品久久久久久水蜜桃| 美女写真久久影院| 国产L精品国产亚洲区久久| 伊人丁香狠狠色综合久久| av无码久久久久不卡免费网站| 成人久久精品一区二区三区| 久久精品国产亚洲AV高清热| 久久精品中文騷妇女内射|