cf B. Eight Point Sets
http://codeforces.com/contest/334/problem/B
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 6 const int maxn=2e6; 7 struct node 8 { 9 int x,y; 10 bool operator <(const node &a)const 11 { 12 return (x<a.x)||(x==a.x&&y<a.y); 13 } 14 }p[maxn]; 15 16 bool deal() 17 { 18 if(p[0].x==p[1].x&&p[0].x==p[2].x&&(p[0].y<p[1].y&&p[1].y<p[2].y)&&(p[3].x==p[4].x&&p[3].y<p[4].y)&&(p[5].x==p[6].x&&p[6].x==p[7].x)&&(p[5].y<p[6].y&&p[6].y<p[7].y)&&(p[0].x<p[3].x&&p[3].x<p[5].x)&&(p[2].y==p[4].y&&p[4].y==p[7].y)&&(p[1].y==p[6].y&&p[0].y==p[3].y&&p[3].y==p[5].y)) 19 return true; 20 else return false; 21 } 22 int main() 23 { 24 for(int i=0; i<8; i++) 25 { 26 scanf("%d%d",&p[i].x,&p[i].y); 27 } 28 sort(p,p+8); 29 if(deal()) 30 printf("respectable\n"); 31 else printf("ugly\n"); 32 return 0; 33 }