Submission #1092338

# Submission time Handle Problem Language Result Execution time Memory
1092338 2024-09-23T20:05:41 Z DeathIsAwe Star triangles (IZhO11_triangle) C++17
100 / 100
179 ms 11844 KB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define ll long long
unordered_map<int,int> xcoords, ycoords;


int main() {
    int n; cin >> n;
    vector<pair<int,int>> coords(n);
    for (int i=0;i<n;i++) {
        cin >> coords[i].ff >> coords[i].ss;
        if (xcoords.find(coords[i].ff) == xcoords.end()) {
            xcoords[coords[i].ff] = 1;
        } else {
            xcoords[coords[i].ff] += 1;
        }

        if (ycoords.find(coords[i].ss) == ycoords.end()) {
            ycoords[coords[i].ss] = 1;
        } else {
            ycoords[coords[i].ss] += 1;
        }
    }


    ll ans = 0;
    for (pair<int,int> i: coords) {
        ans += (ll)(xcoords[i.ff] - 1) * (ll)(ycoords[i.ss] - 1);
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 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 440 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 6 ms 1112 KB Output is correct
13 Correct 6 ms 1112 KB Output is correct
14 Correct 9 ms 1372 KB Output is correct
15 Correct 85 ms 6108 KB Output is correct
16 Correct 70 ms 6152 KB Output is correct
17 Correct 80 ms 5784 KB Output is correct
18 Correct 64 ms 5900 KB Output is correct
19 Correct 171 ms 11016 KB Output is correct
20 Correct 126 ms 8864 KB Output is correct
21 Correct 179 ms 11784 KB Output is correct
22 Correct 176 ms 11844 KB Output is correct