답안 #1116980

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116980 2024-11-22T17:12:57 Z kirakosyan 별들과 삼각형 (IZhO11_triangle) C++17
100 / 100
300 ms 15688 KB
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<random>
#include<cmath>
#include<stack>
#include<map>
#include <iomanip> 
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;
ll pv(ll a, ll b) {
    if (b == 0)return 1;
    ll res = (pv(a, b / 2));
    if (b % 2) {
        return (((res * res) % mod) * (a % mod)) % mod;
    }
    else {
        return (res * res) % mod;
    }
}

void solve() {
    ll n; cin >> n;
    vector<ll>x(n), y(n);
    map<ll, ll>mp, mp1;
    for (ll i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        mp[x[i]]++;
        mp1[y[i]]++;

    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += ((mp[x[i]] - 1) * (mp1[y[i]] - 1));
    }
    cout << ans << endl;


}

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

    ll _ = 1;
    //cin >> _;
    while (_--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 6 ms 1428 KB Output is correct
13 Correct 7 ms 1360 KB Output is correct
14 Correct 11 ms 1872 KB Output is correct
15 Correct 97 ms 8076 KB Output is correct
16 Correct 118 ms 8400 KB Output is correct
17 Correct 104 ms 7864 KB Output is correct
18 Correct 116 ms 8008 KB Output is correct
19 Correct 300 ms 14740 KB Output is correct
20 Correct 218 ms 11848 KB Output is correct
21 Correct 297 ms 15560 KB Output is correct
22 Correct 293 ms 15688 KB Output is correct