제출 #971330

#제출 시각아이디문제언어결과실행 시간메모리
971330vjudge1Star triangles (IZhO11_triangle)C++17
100 / 100
922 ms34436 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int n;
    cin>>n;
    pair<int,int>kartesius[n+1];
    map<int,int >y;
    map<int,int>x;
    map<pair<int,int>,int> cek;

    for(int j=1;j<=n;j++ ){
        cin>>kartesius[j].first>>kartesius[j].second;
        int q=kartesius[j].first;
        int w=kartesius[j].second;

        if(cek[{q,w}]!=1){

            cek[{q,w}]=1;
            if(!x.count(q)){
                x[q]=1;
            }
            else{
                x[q]++;
            }
            if(!y.count(w)){
                y[w]=1;
            }
            else{
                y[w]++;
            }
        }
    }
    int ans=0;
    for(int k=1;k<=n;k++){
        int hori=kartesius[k].first;
        int ver=kartesius[k].second;
        if(cek[{hori,ver}]==1){
            ans+=(x[hori]-1)*(y[ver]-1);
            cek[{hori,ver}]=2;
        }
    }
  //  cout<<cek[{1,1}]<<endl;
    cout<<ans<<endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...