# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107067 | someone_aa | Star triangles (IZhO11_triangle) | C++17 | 1049 ms | 76364 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>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 300100;
int x[maxn], y[maxn];
int n;
set<int>xst, yst;
map<int,int>xind, yind, cnt[maxn];
vector<int>xx[maxn], yy[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++) {
cin>>x[i]>>y[i];
xst.insert(x[i]);
yst.insert(y[i]);
}
int br = 1;
for(int i:xst) {
xind[i] = br++;
}
br = 1;
for(int i:yst) {
yind[i] = br++;
}
for(int i=1;i<=n;i++) {
x[i] = xind[x[i]];
y[i] = yind[y[i]];
xx[x[i]].pb(y[i]);
yy[y[i]].pb(x[i]);
}
for(int i=1;i<=n;i++) {
sort(yy[i].begin(), yy[i].end());
sort(xx[i].begin(), xx[i].end());
int br = 0;
for(int j:yy[i]) {
cnt[i][j] = br++;
}
}
ll result = 0LL;
for(int i=1;i<=n;i++) {
int br = 0;
for(int j:xx[i]) {
int curr_x = i;
int curr_y = j;
int lcnt = cnt[i][j];
int rcnt = yy[curr_y].size() - lcnt - 1;
int dcnt = br;
int ucnt = xx[i].size() - br - 1;
ll temp = 0LL;
temp += 1LL * lcnt * ucnt;
temp += 1LL * lcnt * dcnt;
temp += 1LL * rcnt * ucnt;
temp += 1LL * rcnt * dcnt;
result += temp;
br++;
}
}
cout<<result<<"\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |