# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671811 | moday_morning | Star triangles (IZhO11_triangle) | C++17 | 65 ms | 588 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 300000;
void usaco(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
map <int, int> x, y;
int a[1 + N][2];
void solve() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i][0] >> a[i][1];
}
for (int i = 1; i <= n; i++) {
x[a[i][0]]++;
y[a[i][1]]++;
}
int sum = 0;
for (int i = 1;i <= n; i++) {
sum += 1LL * (x[a[i][0]] - 1) * (y[a[i][1]] - 1);
}
cout << sum << "\n";
}
signed main() {
usaco("triangles");
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |