# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108510 | Nomio | Star triangles (IZhO11_triangle) | C++17 | 228 ms | 14408 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>
using namespace std;
using ll = long long;
const int maxn = 6e5;
int a[maxn + 1] {}, b[maxn + 1] {};
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
set<int> S;
int x[n], y[n];
for(int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
S.insert(x[i]);
S.insert(y[i]);
}
int c = 0;
map<int, int> m;
for(int X : S) {
m[X] = c;
c++;
}
for(int i = 0; i < n; i++) {
x[i] = m[x[i]];
y[i] = m[y[i]];
}
for(int i = 0; i < n; i++) {
a[x[i]]++;
b[y[i]]++;
}
ll cnt = 0;
for(int i = 0; i < n; i++) {
cnt += 1LL * (a[x[i]] - 1) * (b[y[i]] - 1);
}
cout << cnt << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |