답안 #531534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
531534 2022-03-01T02:22:49 Z christinelynn 별들과 삼각형 (IZhO11_triangle) C++17
100 / 100
400 ms 10208 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  cin.tie(0) -> ios_base::sync_with_stdio(0);

  int n;
  cin >> n;
  vector<int> x(n), y(n);
  map<int,int> px, py;
  for(int i=0;i<n;i++)
  {
    cin >> x[i] >> y[i];
    px[x[i]]++;
    py[y[i]]++;
  }
  int ans = 0;
  for(int i=0;i<n;i++)
  {
    int cx = 0, cy = 0;
    if(px.count(x[i])) cx = px[x[i]];
    if(py.count(y[i])) cy = py[y[i]];
    ans += (cx - 1) * (cy - 1);
  }
  cout << ans << '\n';
  
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 7 ms 1228 KB Output is correct
13 Correct 7 ms 1228 KB Output is correct
14 Correct 12 ms 1748 KB Output is correct
15 Correct 135 ms 6612 KB Output is correct
16 Correct 132 ms 6936 KB Output is correct
17 Correct 121 ms 6872 KB Output is correct
18 Correct 142 ms 6792 KB Output is correct
19 Correct 336 ms 10044 KB Output is correct
20 Correct 270 ms 8568 KB Output is correct
21 Correct 366 ms 10208 KB Output is correct
22 Correct 400 ms 10168 KB Output is correct