Submission #901394

# Submission time Handle Problem Language Result Execution time Memory
901394 2024-01-09T11:35:19 Z LOLOLO Star triangles (IZhO11_triangle) C++14
100 / 100
268 ms 16320 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x)   (int)(x).size()
#define len(x)  (int)(x).length()
#define cntbit(x)  builtin_popcnt(x)
#define f   first
#define s   second
#define pb  push_back


ll solve() {
    int n;
    cin >> n;

    vector <pair <int, int>> save;
    map <int, ll> row, col;
    for (int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        row[x]++;
        col[y]++;
        save.pb(make_pair(x, y));
    }

    ll ans = 0;
    for (auto x : save) {
        ans += (row[x.f] - 1) * (col[x.s] - 1);
    }

    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    //cin >> t;

    while (t--) {
        cout << solve() << '\n';
    }

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 348 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 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1116 KB Output is correct
13 Correct 5 ms 1372 KB Output is correct
14 Correct 8 ms 1628 KB Output is correct
15 Correct 92 ms 7236 KB Output is correct
16 Correct 97 ms 7376 KB Output is correct
17 Correct 84 ms 7244 KB Output is correct
18 Correct 83 ms 7092 KB Output is correct
19 Correct 231 ms 16320 KB Output is correct
20 Correct 197 ms 10160 KB Output is correct
21 Correct 268 ms 16320 KB Output is correct
22 Correct 256 ms 16064 KB Output is correct