Submission #481037

# Submission time Handle Problem Language Result Execution time Memory
481037 2021-10-19T09:59:35 Z dxz05 Star triangles (IZhO11_triangle) C++14
100 / 100
379 ms 9960 KB
#pragma GCC optimize("Ofast,O2,O3,unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << "[" << H << "]";
    debug_out(T...);
}

#ifdef dddxxz
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SZ(s) ((int)s.size())
#define all(x) (x).begin(), (x).end()
#define lla(x) (x).rbegin(), (x).rend()

clock_t startTime;

double getCurrentTime() {
    return (double) (clock() - startTime) / CLOCKS_PER_SEC;
}

#define MP make_pair

typedef long long ll;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const double eps = 0.000001;
const int MOD = 998244353;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
const int N = 2e6 + 2e5;
const int M = 5222;

int x[N], y[N];
void solve(int TC) {
    int n;
    cin >> n;

    map<int, int> a, b;
    for (int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        a[x[i]]++;
        b[y[i]]++;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += 1ll * (a[x[i]] - 1) * (b[y[i]] - 1);
    }

    cout << ans;

}

int main() {
    startTime = clock();
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

#ifdef dddxxz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int TC = 1;
//    cin >> TC;

    for (int test = 1; test <= TC; test++) {
        //debug(test);
        //cout << "Case #" << test << ": ";
        solve(test);
    }

    cerr << endl << "Time: " << int(getCurrentTime() * 1000) << " ms" << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 7 ms 972 KB Output is correct
13 Correct 7 ms 972 KB Output is correct
14 Correct 15 ms 1444 KB Output is correct
15 Correct 125 ms 6084 KB Output is correct
16 Correct 132 ms 6628 KB Output is correct
17 Correct 120 ms 6200 KB Output is correct
18 Correct 149 ms 6148 KB Output is correct
19 Correct 316 ms 9668 KB Output is correct
20 Correct 294 ms 9120 KB Output is correct
21 Correct 353 ms 9848 KB Output is correct
22 Correct 379 ms 9960 KB Output is correct