답안 #379680

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
379680 2021-03-19T02:42:45 Z SolarSystem 별들과 삼각형 (IZhO11_triangle) C++17
100 / 100
502 ms 18156 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <random>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector<pair<long long, long long>> pts(n);

    for (int i = 0; i < n; i++) {
        cin >> pts[i].first >> pts[i].second;
    }

    map<long long, long long> mpx;
    map<long long, vector<long long>> mpy;

    for (int i = 0; i < n; i++) {
        mpx[pts[i].first]++;
        mpy[pts[i].second].push_back(pts[i].first);
    }

    long long ans = 0;

    for (auto e: mpy) {
        long long curr = 0;

        for (auto u: e.second) {
            curr += mpx[u] - 1;
        }

        curr *= ((int) e.second.size() - 1);

        ans += curr;
    }

    cout << ans << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 14 ms 1772 KB Output is correct
13 Correct 10 ms 1644 KB Output is correct
14 Correct 11 ms 2156 KB Output is correct
15 Correct 130 ms 10092 KB Output is correct
16 Correct 147 ms 10732 KB Output is correct
17 Correct 136 ms 10220 KB Output is correct
18 Correct 143 ms 10092 KB Output is correct
19 Correct 450 ms 17320 KB Output is correct
20 Correct 326 ms 14572 KB Output is correct
21 Correct 499 ms 18156 KB Output is correct
22 Correct 502 ms 17972 KB Output is correct