답안 #480987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
480987 2021-10-19T06:13:43 Z FatihSolak 별들과 삼각형 (IZhO11_triangle) C++17
100 / 100
544 ms 13732 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef Local
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    int n;
    cin >> n;
    long long ans = 0;
    map<int,int> cnt;
    vector<pair<int,int>> v;
    for(int i=1;i<=n;i++){
        int x,y;
        cin >> x >> y;
        cnt[y]++;
        v.push_back({y,x});
    }
    map<int,int> mp;
    for(auto u:v){
        mp[u.second] += cnt[u.first] - 1;
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    map<int,int> mp2;
    for(auto u:v){
        mp[u.second] -= cnt[u.first] - 1;
        ans += mp[u.second] + mp2[u.second];
        mp2[u.second] += cnt[u.first] - 1;
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 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 9 ms 972 KB Output is correct
13 Correct 9 ms 1212 KB Output is correct
14 Correct 16 ms 1804 KB Output is correct
15 Correct 190 ms 7528 KB Output is correct
16 Correct 228 ms 7932 KB Output is correct
17 Correct 180 ms 7560 KB Output is correct
18 Correct 193 ms 7664 KB Output is correct
19 Correct 467 ms 13052 KB Output is correct
20 Correct 355 ms 10796 KB Output is correct
21 Correct 502 ms 13668 KB Output is correct
22 Correct 544 ms 13732 KB Output is correct