# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
465909 | JasperL | 별들과 삼각형 (IZhO11_triangle) | C++14 | 572 ms | 12488 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 <set>
#include <map>
#include <vector>
using namespace std;
#define maxn 300005
typedef long long ll;
int n, c;
int z[maxn][2];
set<int> s;
map<int,int> mp;
ll ans = 0;
int x[2*maxn], y[2*maxn];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> z[i][0] >> z[i][1];
s.insert(z[i][0]), s.insert(z[i][1]);
}
for (int t : s) mp[t] = c++;
for (int i = 0; i < n; i++) z[i][0] = mp[z[i][0]], z[i][1] = mp[z[i][1]], x[z[i][0]]++, y[z[i][1]]++;
for (int i = 0; i < n; i++) {
ans += (ll)(x[z[i][0]] - 1) * (ll)(y[z[i][1]] - 1);
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |