Submission #856491

# Submission time Handle Problem Language Result Execution time Memory
856491 2023-10-03T17:16:31 Z aykhn Star triangles (IZhO11_triangle) C++14
100 / 100
681 ms 37672 KB
#include <bits/stdc++.h>

// author : aykhn

using namespace std;
typedef long long ll;

#define pb push_back
#define ins insert
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define bpc __builtin_popcount
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define int ll
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F

map<pii, int> mp;
signed main()
{
    int n;
    cin >> n;
    vector<int> x, y;
    vector<pii> c;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b; 
        c.pb(mpr(a, b));
        x.pb(a);
        y.pb(b);
        mp[mpr(a, b)]++;
    }
    sort(all(x));
    sort(all(y));
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        int c1 = upper_bound(all(x), c[i].fi) - lower_bound(all(x), c[i].fi);
        int c2 = upper_bound(all(y), c[i].se) - lower_bound(all(y), c[i].se);
        c1 -= mp[c[i]];
        c2 -= mp[c[i]];
        res += c1 * c2;
    }
    cout << res << '\n';
    
}
# Verdict Execution time Memory 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 0 ms 348 KB Output is correct
8 Correct 0 ms 344 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 13 ms 1448 KB Output is correct
13 Correct 13 ms 1492 KB Output is correct
14 Correct 15 ms 1496 KB Output is correct
15 Correct 183 ms 11968 KB Output is correct
16 Correct 214 ms 13060 KB Output is correct
17 Correct 179 ms 11988 KB Output is correct
18 Correct 182 ms 11964 KB Output is correct
19 Correct 625 ms 37112 KB Output is correct
20 Correct 422 ms 23896 KB Output is correct
21 Correct 681 ms 37296 KB Output is correct
22 Correct 678 ms 37672 KB Output is correct