codeforces194b

August 15, 2013
CodeForces

link:http://codeforces.com/problemset/problem/334/B


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
const int dir[8][2] = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{-1,1},{1,-1},{1,1}};
using namespace std;
int main(void)
{
    set<int> sadx, sady;
    int x[9] ,y[9] ;
    bool flag = true;
    for (int i=0;i<8;++i)
    {
        scanf("%d%d",&x[i],&y[i]);
        sadx.insert(x[i]); sady.insert(y[i]);
        for (int j=0;j<i;++j)
        {
            if (x[j]==x[i]&&y[j]==y[i])
            {
                flag = false;
            }
        }
    }
        if(!(sadx.size()==3&&sady.size()==3)) {
            flag = false;
        }
        int midx, midy; midx=*(++sadx.begin());
        midy=*(++sady.begin());
        for (int i=0;i<8;++i)
        {
            if(midx==x[i]&&midy==y[i])
            {
                flag=false; break;
            }
        }
        if(flag) printf("respectable\n");
        else printf("ugly\n");

        return 0;
}

关键就是思路清晰,想清楚。 首先,8个点不能有相同的,然后,横纵坐标必须都是3个不同的数字。然后要找到中间的点,一定是不存在的,若存在就不符合。

comments powered by Disqus