답안 #859902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
859902 2023-10-11T05:29:59 Z AtabayRajabli 별들과 삼각형 (IZhO11_triangle) C++11
100 / 100
434 ms 30236 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// author : AtabeyR

#define pb          push_back
#define pii         pair<int, int>
#define pll         pair<ll, ll>
#define all(v)      v.begin(), v.end()
#define OPT         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sec         second
#define fi          first
#define int         ll
#define print(k)    cerr << "Ans : "; cout << k << endl;
#define ins         insert
#define bpc         __builtin_popcountll
#define skip        continue
#define endll        "\n"
#define li          2*ind+1
#define ri          2*ind+2
#define lb          lower_bound
#define ub          upper_bound

typedef long long ll;
typedef unsigned long long ull;
const int oo = 0x3F3F3F3F;
const int ooo = 0x3F3F3F3F3F3F3F3FLL;
const int mod = 998244353;
const int sz = 3e5+6;
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

int lcm(int a, int b)
{
    return a*b / (__gcd(a, b));
}
int gcd(int a, int b)
{
    return __gcd(a, b);
}

int n, m, k;

void proud(int balls)
{
    cin >> n;

    vector<int> x, y;
    map<int, int> mx, my;
    map<pii, int> mp;
    for(int i = 1; i<=n; i++)
    {
        int xx, yy;
        cin >> xx >> yy;

        mx[xx]++;
        my[yy]++;
        mp[pii(xx, yy)]++;
    }

    int res = 0;
    for(pair<pii, int> p : mp)
    {
        int c1 = mx[p.fi.fi] - 1;
        int c2 = my[p.fi.sec] - 1;

        res += c1 * c2 * p.sec;
    }

    cout << res << endll;
}

int32_t main()  
{

    // freopen("i.txt", "r", stdin);
    // freopen("o.txt", "w", stdout);

    OPT
    int t = 1;
    //cin >> t;

    for(int i = 1; i<=t; i++)
        proud(i);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 1 ms 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 7 ms 1628 KB Output is correct
13 Correct 6 ms 1884 KB Output is correct
14 Correct 10 ms 2140 KB Output is correct
15 Correct 113 ms 12636 KB Output is correct
16 Correct 122 ms 13560 KB Output is correct
17 Correct 111 ms 12708 KB Output is correct
18 Correct 111 ms 12648 KB Output is correct
19 Correct 419 ms 27728 KB Output is correct
20 Correct 261 ms 21576 KB Output is correct
21 Correct 433 ms 29816 KB Output is correct
22 Correct 434 ms 30236 KB Output is correct