답안 #996675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996675 2024-06-11T04:53:43 Z p4r4d0_x 별들과 삼각형 (IZhO11_triangle) C++14
100 / 100
286 ms 15700 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PUT(a, b) freopen(a, "r", stdin); freopen(b, "w", stdout);
#define all(a) a.begin(), a.end()
#define answerNO {cout << "NO" << endl; return;}
#define answerYES {cout << "YES" << endl; return;}
using namespace std;
//#define int long long
#define ff first
#define ss second
#define pb push_back
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll mod = 1e9+7;


ll n;





void solve(){
    ll n; cin >> n;
    map<ll, ll> m1;
    map<ll, ll> m2;
    vector<pair<ll, ll>> a(n);
    rep(i, n){
        cin >> a[i].ff >> a[i].ss;
        m1[a[i].ff]++;
        m2[a[i].ss]++;
    }
    ll ans = 0;
    rep(i, n){
        ans += ((m1[a[i].ff] - 1) * (m2[a[i].ss] - 1));
    }
    cout << ans << "\n";
}




signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    //PUT("diamond.in", "diamond.out");
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 464 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 4 ms 1300 KB Output is correct
14 Correct 8 ms 1880 KB Output is correct
15 Correct 90 ms 7836 KB Output is correct
16 Correct 123 ms 8236 KB Output is correct
17 Correct 90 ms 7920 KB Output is correct
18 Correct 92 ms 8012 KB Output is correct
19 Correct 255 ms 14840 KB Output is correct
20 Correct 182 ms 11804 KB Output is correct
21 Correct 286 ms 15700 KB Output is correct
22 Correct 279 ms 15496 KB Output is correct