Submission #687495

# Submission time Handle Problem Language Result Execution time Memory
687495 2023-01-26T12:51:37 Z speedyArda Star triangles (IZhO11_triangle) C++14
100 / 100
797 ms 18464 KB
#include "bits/stdc++.h"

using namespace std;
// Even though the previous solution is correct (https://oj.uz/submission/687487), We might need to hold our coordinates inside of a set rather than an array because there might be stars who have same coordinates.
map<int, long long> x_cnt;
map<int, long long> y_cnt;
int main() 
{
    int n;
    cin >> n;

    set< pair<int, int> > coords;
    for(int i = 0; i < n; i++) {
        pair<int, int> star;
        cin >> star.first >> star.second;
        x_cnt[star.first]++;
        y_cnt[star.second]++;
        coords.insert(star);
    }
    //sort(coords, coords + n);
    long long ans = 0;

    for(pair<int, int> star : coords)
    {
        ans += (x_cnt[star.first] - 1) * (y_cnt[star.second] - 1);
    }

    cout << ans << "\n";

    
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 12 ms 1340 KB Output is correct
13 Correct 12 ms 1360 KB Output is correct
14 Correct 17 ms 1732 KB Output is correct
15 Correct 222 ms 8944 KB Output is correct
16 Correct 250 ms 9408 KB Output is correct
17 Correct 256 ms 8888 KB Output is correct
18 Correct 208 ms 8964 KB Output is correct
19 Correct 661 ms 17500 KB Output is correct
20 Correct 468 ms 13724 KB Output is correct
21 Correct 758 ms 18464 KB Output is correct
22 Correct 797 ms 18380 KB Output is correct