# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
879914 | dubabuba | Star triangles (IZhO11_triangle) | C++14 | 444 ms | 18456 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;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define ff first
#define ss second
const int mxn = 3e5 + 10;
int n, id[mxn], s = 1;
map<int, int> mp;
vector<vi> x;
vector<vi> y;
pii p[mxn];
int main() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> p[i].ff >> p[i].ss;
id[i] = i;
mp[p[i].ff];
mp[p[i].ss];
}
for(auto &t : mp) {
t.ss = s;
s++;
}
x.resize(s);
y.resize(s);
for(int i = 1; i <= n; i++) {
p[i].ff = mp[p[i].ff];
p[i].ss = mp[p[i].ss];
x[p[i].ff].push_back(i);
y[p[i].ss].push_back(i);
}
int ans = 0;
for(int i = 1; i <= n; i++) {
int X = p[i].ff, Y = p[i].ss;
int chx = x[X].size() - 1;
int chy = y[Y].size() - 1;
ans += chx * chy;
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |