Poj Solution 2582

http://poj.org/problem?id=2582

#include<iostream>
#include"math.h"
using namespace std;

struct point
{
    int x,y,z;
}b[20],f[20];

inline int sq_dis( point a, point b )
{
    return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + (a.z-b.z)*(a.z-b.z);
}

int main()
{
    int l,w,d,n,m,ans,i,j;
    char t[100],c;

    cin>>t;
    while( cin>>l>>w>>d )
    {

        m = 0;
        while( 1 )
        {
            cin>>b[m].x>>c>>b[m].y>>c>>b[m].z;
            if( b[m].z > d ) b[m].z = d;

            m++;
            if( cin.peek() == 'n' ) break;
        }

        n = 0;
        while( 1 )
        {
            cin>>f[n].x>>c>>f[n].y>>c>>f[n].z;
            
            n++;
            if( cin.peek() == 'n' ) break;
        }

        ans = 0;
        for( i=0; i<n; i++ )
        for( j=0; j<m; j++ )
            if( sq_dis( f[i], b[j] ) <=1 )
            {
                ans++;
                break;
            }

        if( ans != 0 ) cout<<"AIEE, I got "<<ans<<" fish, me!n";
        else cout<<"None of dem fish blowed up!n";

        cin>>t>>t;

    }
    return 0;

}
											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *