Codeforces Supercentral Point


#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
#define mset(c,v) memset(c , v , sizeof c)
#define loop0(n) for(int i=0; i<n; i++)
#define loop1(n) for(int i=1; i<=n; i++)
#define mpair(x , y) make_pair(x , y)
#define all(x) x.begin(), x.end()
#define pi acos(-1.0)
#define psb push_back

typedef unsigned long long ull;
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef vector<string>vs;
typedef map<int, int>mpii;
typedef map<string, int>mpsi;
typedef map<char, int>mpci;
typedef map<LL, LL>mpll;

const int mod = 1000007;
const int high = 202;

int main()
{
    fast;
    map<pair<int,int>, int>mpr;
    pair<int,int>pii[high];
    int N;
    while(cin >> N)
    {
        mpr.clear();

        for(int i=1; i<=N; i++)
        {
            int x , y;

            cin >> x >> y;

           pii[i].first = x;
           pii[i].second = y;

            //mpr[make_pair(x , y)] = 0;
        }

        //for(int i=1; i<=N; i++) cout << pii[i].first << " -> " << pii[i].second << "\n";

        //cout << "\n\n";

        int x , y;

        int cnt = 0;

        for(int i=1; i<=N; i++)
        {
            x = pii[i].first;
            y = pii[i].second;

            bool rgt = false, lft = false, low = false , up = false;

            //cout << "\n" << x << " " << y << "\n\n";

            for(int j=1; j<=N; j++)
            {
                int x1 = pii[j].first;
                int y1 = pii[j].second;

                if(x1 > x && y1 == y) rgt = true; //cout << "->" << x1 << " " << y1 << "\n";
                if(x1 < x && y1 == y) lft = true; //cout << "->" << x1 << " " << y1 << "\n";;
                if(x1 == x && y1 > y) up = true; //cout << "->" << x1 << " " << y1 << "\n";;
                if(x1 == x && y1 < y) low = true; //cout << "->" << x1 << " " << y1 << "\n";;

                //cout << x1 << " " << y1 << "\n";
            }

            if(rgt==true && lft == true && up == true && low == true) cnt+=1;
        }

        outn(cnt);
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number