# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
531725 | kebine | Star triangles (IZhO11_triangle) | C++17 | 691 ms | 11988 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;
#define ll long long
int n;
pair<int, int> star[300005];
map<int, int> x, y;
int main() {
cin >> n;
for(int i = 0; i < n; i++) {
cin >> star[i].first >> star[i].second;
//cout << star[i].first << " " << star[i].second << endl;
if(x.count(star[i].first) > 0) {
int now = x.find(star[i].first) -> second;
x.erase(star[i].first);
x.insert({star[i].first, now + 1});
//cout << "x" << now << endl;
}
else {
x.insert({star[i].first, 1});
}
if(y.count(star[i].second) > 0) {
int now = y.find(star[i].second) -> second;
y.erase(star[i].second);
y.insert({star[i].second, now + 1});
//cout << "y" << now << endl;
}
else {
y.insert({star[i].second, 1});
}
}
ll ans = 0;
for(int i = 0; i < n; i++) {
int hor = x.find(star[i].first) -> second;
hor--;
int ver = y.find(star[i].second) -> second;
ver--;
ans += 1ll * ver * hor;
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |