Submission #765530

# Submission time Handle Problem Language Result Execution time Memory
765530 2023-06-24T18:19:18 Z nguyen31hoang08minh2003 Star triangles (IZhO11_triangle) C++17
100 / 100
240 ms 12216 KB
#include <bits/stdc++.h>
using namespace std;

template<class X, class Y>
bool minimize(X &x, const Y &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<class X, class Y>
bool maximize(X &x, const Y &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

constexpr int MAX_N = 300005;

int N, X[MAX_N], Y[MAX_N];
map<int, int> x, y;
long long result;

signed main() {
    #ifdef LOCAL
        freopen("input.INP", "r", stdin);
//        freopen("log.TXT", "w", stderr);
//        freopen("output.out", "w", stdout);
    #endif
    cin.tie(0) -> sync_with_stdio(0);
    cout.tie(0);

    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> X[i] >> Y[i];
        ++x[X[i]];
        ++y[Y[i]];
    }

    for (int i = 1; i <= N; ++i)
        result += (x[X[i]] - 1LL) * (y[Y[i]] - 1LL);

    cout << result << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 360 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 5 ms 976 KB Output is correct
13 Correct 5 ms 980 KB Output is correct
14 Correct 8 ms 1364 KB Output is correct
15 Correct 81 ms 6164 KB Output is correct
16 Correct 88 ms 6476 KB Output is correct
17 Correct 82 ms 6092 KB Output is correct
18 Correct 87 ms 6196 KB Output is correct
19 Correct 218 ms 11496 KB Output is correct
20 Correct 157 ms 9260 KB Output is correct
21 Correct 240 ms 12216 KB Output is correct
22 Correct 238 ms 12108 KB Output is correct