제출 #975180

#제출 시각아이디문제언어결과실행 시간메모리
975180vjudge1별들과 삼각형 (IZhO11_triangle)C++17
100 / 100
271 ms13788 KiB
#include <bits/stdc++.h>
typedef long double ld;
#define int long long
#define TC int t; cin >> t; for(int _=1; _<=t; _++)
#define pii pair<int, int>
#define pb push_back
#define ffl fflush(stdout)
using namespace std;

signed main(){
   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int n; cin >> n;
   map<int, int> mapx, mapy;
   vector<pii> res;
   for(int i=0; i<n; i++){
      int x, y; cin >> x >> y;
      mapx[x]++;
      mapy[y]++;
      res.pb(make_pair(x, y));
   }

   int ans = 0;
   for(int i=0; i<n; i++){
      int x = res[i].first, y = res[i].second;
      int cntx = mapx[x]-1;
      int cnty = mapy[y]-1;

      if(cntx>0 && cnty>0){
         ans+=(cntx*cnty);
      }
   }
   cout << ans;
   //cout << (4*(99*99)) + 200;
   //cout << 99*99;
}
#Verdict Execution timeMemoryGrader output
Fetching results...