Luo Gu P3958 cheese explanations

Ideas:

Behold the first two points can communicate, then wide search to find the next step, if it reaches a height h output Yes, if all paths are approached can not reach the height h on output No.

#include<bits/stdc++.h> 
using namespace std;
long long t;
long long n,h,r;
long long x[1005],y[1005],z[1005];
long long maap[1005][1005];
long long book[1005];
long long flag=0;
long long p;//用long long(数据范围大) 
int juli(long long a,long longB, Long  Long C, Long  Long D, Long  Long E, Long  Long F) 
{ 
    Double SUM1 = sqrt ((ab &) * (ab &) + (CD) * (CD) + (EF) * (EF)); / / distance between two points is determined 
    Double BJ = 2 * R & lt; // Double neither burst can deal with a problem fractional 
    IF (SUM1 <= BJ) return  . 1 ; // if the distance is equal to two less than the center two radius described two holes attached to 
    the else  return  0 ; 
} 
int main () 
{ 
    CIN >> T; 
    Queue < int > Q;// initialize queue 
    the while (T--) // T set of data 
    { 
        In Flag = 0 ; // decided whether or not output 
        the while (! Q.empty ()) q.pop (); 
        Memset (Book, 0 , the sizeof (Book )); 
        Memset (MAAP, 0 , the sizeof (MAAP)); // initialize 
         // MAAP MAAP stored map [i] [j] i and j can store connected 
        CIN H >> >> >> n-R & lt; // input 
        for ( Long  Long I = . 1 ; I <= n-; I ++ ) 
        { 
            CINX >> [i] >> Y [i] >> Z [i]; // input 
            IF (Z [i] R & lt +> = H) Book [i] = 2 ; // Analyzing can to the i-th top, if Book [I] 2 = 
            IF (Z [I] -R & lt <= 0 ) q.push (I); // if this could point to the ground out of it, pushing the queue, ready wide search 
        }
         for ( Long  Long I = . 1 ; I <= n-; I ++ )
             for ( Long  Long J = I; J <= n-; J ++ )
                 IF (Juli (X [I], X [J], Y [I], Y [ J], Z [I], Z [J]) == . 1 ) 
                { 
                    MAAP [I] [J] = . 1 ;
                    MAAP [j] [i]= 1 ; 
                } // determines whether i and j are connected, stored in maap in 
        the while (! Q.empty ()) 
        { 
            P = q.front (); // get a broad search start point 
            q.pop (); // search through a point POP 
            IF (Book [p] == 2 ) 
            { 
                COUT << " Yes " << endl; 
                in Flag = . 1 ;
                 BREAK ; 
            } // if the point p may be the top layer, outputs yes, flag = 1 (representing the output has been too) 
            IF )(Book [P] =! . 1 
            { 
                Book [P] = . 1 ; // a point can not be repeated down (actually can, but no meaning 
                for ( Long  Long K = . 1 ; K <= n-; K ++ )
                     IF (MAAP [P ] [k] == . 1 ) // if the current point p may point k 
                        q.push (k); // the push queue k, wide search 
            } 
        } 
        IF (in Flag == 0 ) // if flag = 0, indicating no output over, that is to say not to the top floor, the output -1; 
            COUT << " no " << endl; 
    } 
    return  0 ;
}
Please Gangster treatise(Anyway, I do not know what that means treatise)
 

 

Guess you like

Origin www.cnblogs.com/handsome-zyc/p/11237451.html