제출 #971964

#제출 시각아이디문제언어결과실행 시간메모리
971964vjudge1별들과 삼각형 (IZhO11_triangle)C++17
0 / 100
1 ms428 KiB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

vector<pair<int, int>> p;

int main(){
  int n; cin >> n; 
  p.resize(n);
  for(int i = 0; i < n; i++) {
    int x, y; cin >> x >> y;
    p[i].first = x; p[i].second = y;
  }

  std::map<int, int> horizontal, vertical;

  for (auto const & x : p)
  {
      horizontal[x.first]++;
      vertical[x.second]++;
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    int h = horizontal[p[i].first]-1;
    int v = vertical[p[i].second]-1;
    if(h > 0 && v > 0){
      horizontal[p[i].first]--;
      vertical[p[i].second]--;
      ans++;
    }
  }
  cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...