Poj Solution 1314

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

#include<iostream>
using namespace std;
int main()
{int p[27][3],n,cas,line;
int i,j,k,h,jie;char a;
cas=1;

while(1)
{cin>>n;
if(cin.fail())break;
if(n==0)break;

for(i=0;i<n;i++){cin>>a;p[i][0]=a;cin>>p[i][1];cin>>p[i][2];}
line=0;jie=0;
cout<<"Point set "<<cas<<":";
for(i=0;i<n;i++)
{for(j=0;j<n;j++)if(p[i][2]==p[j][2]&&p[i][1]<p[j][1])
    {for(k=0;k<n;k++)if(p[k][1]==p[j][1]&&p[k][2]<p[j][2])
        {for(h=0;h<n;h++)if(p[h][1]==p[i][1]&&p[h][2]==p[k][2])
                {if(line==0)cout<<endl;
                    cout<<' '<<(char)p[i][0]<<(char)p[j][0]<<(char)p[k][0]<<(char)p[h][0];
                    line++;if(line%10==0){cout<<endl;}}
}}}
if(line==0)cout<<" No rectangles"<<endl;
else if(line%10!=0)cout<<endl;
cas++;
}
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 *