2017 Multi-University Training Contest 2 hdu 6055

HDU 6055

思路:

 

AC代码:

#include "iostream"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#define ll long long
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a) memset(a,0,sizeof(a))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define lrt (rt*2)
#define rrt (rt*2+1)
using namespace std;
const long long INF = 1e18+1LL;
const int inf = 1e9+1e8;
const int N=2e5+50000;
const ll mod=1e9+7;

const int e=105;
map<pair<int,int>,int> M;
int x[520],y[520];
int n,ans,ans1,ans2,ans3;
int main(){
    while(cin>>n){
        M.clear();
        mem(x),mem(y);
        int ans=0;
        for(int i=1; i<=n; ++i){
            cin>>x[i]>>y[i];
           M[mp(x[i],y[i])]=1;
        }
        for(int i=1; i<=n; ++i){
            for(int j=1; j<=n; ++j){
                if(i==j) continue;
                if(x[i]==x[j] && y[i]>y[j]){
                    int yy=y[i]-y[j];
                    if(M[mp(x[i]+yy,y[i])] && M[mp(x[i]+yy,y[j])]) ans++;
                }
                else{
                    if(x[i]<x[j] && y[i]<y[j]){
                        int xx=x[j]-x[i];
                        int yy=y[j]-y[i];
                        if(M[mp(x[j]+yy,y[j]-xx)] && M[mp(x[i]+yy,y[i]-xx)]) ans++;
                    }
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}

 

posted on 2017-08-23 23:23  lazzzy  阅读(117)  评论(0编辑  收藏  举报

导航