답안 #881882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
881882 2023-12-02T07:10:59 Z vjudge1 별들과 삼각형 (IZhO11_triangle) C++17
100 / 100
242 ms 9332 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    const int lim=2e5+100;
#else
    const int lim=3e3;
#endif

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back

const int mod=1e9+7;
using pii=pair<int,int>;

void solve(){
    int n;
    cin>>n;
    pii a[n];
    map<int,int>col,row;
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
        col[a[i].first]++,row[a[i].second]++;
    }
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=(col[a[i].first]-1)*(row[a[i].second]-1);
    }
    cout<<ans<<"\n";
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
#else
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 360 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1116 KB Output is correct
13 Correct 5 ms 1116 KB Output is correct
14 Correct 8 ms 1612 KB Output is correct
15 Correct 91 ms 5840 KB Output is correct
16 Correct 87 ms 5884 KB Output is correct
17 Correct 80 ms 5716 KB Output is correct
18 Correct 80 ms 5704 KB Output is correct
19 Correct 221 ms 9008 KB Output is correct
20 Correct 154 ms 7508 KB Output is correct
21 Correct 230 ms 9144 KB Output is correct
22 Correct 242 ms 9332 KB Output is correct