# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
678654 | yellowtoad | Star triangles (IZhO11_triangle) | C++17 | 7 ms | 9924 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 <iostream>
#include <vector>
using namespace std;
const long long int mod = 1e5+7;
long long int n, x, y, ans;
pair<long long int, long long int> a[300010];
vector<pair<long long int,long long int>> hx[mod], hy[mod];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].first >> a[i].second;
for (int j = 0; j < hx[a[i].first%mod].size(); j++) {
if (hx[a[i].first%mod][j].first == a[i].first) {
hx[a[i].first%mod][j].second++;
goto skip;
}
}
hx[a[i].first%mod].push_back({a[i].first,1});
skip:;
for (int j = 0; j < hy[a[i].second%mod].size(); j++) {
if (hy[a[i].second%mod][j].first == a[i].second) {
hy[a[i].second%mod][j].second++;
goto skipp;
}
}
hy[a[i].second%mod].push_back({a[i].second,1});
skipp:;
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < hx[a[i].first%mod].size(); j++) {
if (hx[a[i].first%mod][j].first == a[i].first) {
x = hx[a[i].first%mod][j].second;
goto skippp;
}
}
skippp:;
for (int j = 0; j < hy[a[i].second%mod].size(); j++) {
if (hy[a[i].second%mod][j].first == a[i].second) {
y = hy[a[i].second%mod][j].second;
goto skipppp;
}
}
skipppp:;
ans += (x-1)*(y-1);
}
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |