Submission #465909

# Submission time Handle Problem Language Result Execution time Memory
465909 2021-08-17T10:00:42 Z JasperL Star triangles (IZhO11_triangle) C++14
100 / 100
572 ms 12488 KB
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;

#define maxn 300005

typedef long long ll;

int n, c;
int z[maxn][2];
set<int> s;
map<int,int> mp;
ll ans = 0;

int x[2*maxn], y[2*maxn];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> z[i][0] >> z[i][1];
        s.insert(z[i][0]), s.insert(z[i][1]);
    }
    for (int t : s) mp[t] = c++;
    for (int i = 0; i < n; i++) z[i][0] = mp[z[i][0]], z[i][1] = mp[z[i][1]], x[z[i][0]]++, y[z[i][1]]++;
    for (int i = 0; i < n; i++) {
        ans += (ll)(x[z[i][0]] - 1) * (ll)(y[z[i][1]] - 1);
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 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 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 16 ms 1472 KB Output is correct
13 Correct 16 ms 1516 KB Output is correct
14 Correct 21 ms 2124 KB Output is correct
15 Correct 184 ms 6528 KB Output is correct
16 Correct 214 ms 6828 KB Output is correct
17 Correct 189 ms 6472 KB Output is correct
18 Correct 186 ms 6508 KB Output is correct
19 Correct 541 ms 11800 KB Output is correct
20 Correct 376 ms 9412 KB Output is correct
21 Correct 572 ms 12428 KB Output is correct
22 Correct 546 ms 12488 KB Output is correct