답안 #896529

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
896529 2024-01-01T15:41:02 Z borisAngelov 별들과 삼각형 (IZhO11_triangle) C++17
100 / 100
80 ms 11860 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 300005;

int n;

pair<int, int> a[maxn];

unordered_map<int, int> byX;
unordered_map<int, int> byY;

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i].first >> a[i].second;
        ++byX[a[i].first];
        ++byY[a[i].second];
    }

    long long ans = 0;

    for (int i = 1; i <= n; ++i)
    {
        int cnt1 = byX[a[i].first] - 1;
        int cnt2 = byY[a[i].second] - 1;
        ans += (1LL * cnt1) * (1LL * cnt2);
    }

    cout << ans << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 4 ms 980 KB Output is correct
13 Correct 3 ms 1116 KB Output is correct
14 Correct 5 ms 1236 KB Output is correct
15 Correct 30 ms 7452 KB Output is correct
16 Correct 33 ms 7644 KB Output is correct
17 Correct 30 ms 7444 KB Output is correct
18 Correct 31 ms 7440 KB Output is correct
19 Correct 72 ms 11252 KB Output is correct
20 Correct 53 ms 9476 KB Output is correct
21 Correct 80 ms 11860 KB Output is correct
22 Correct 78 ms 11780 KB Output is correct