# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
902324 | dsyz | Star triangles (IZhO11_triangle) | C++17 | 826 ms | 19780 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;
using ll = long long;
#define MAXN (1000005)
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
ll N;
cin>>N;
pair<ll,ll> arr[N];
map<ll,ll> rowcnt, colcnt, row, col;
for(ll i = 0;i < N;i++){
cin>>arr[i].first>>arr[i].second;
rowcnt[arr[i].first]++;
colcnt[arr[i].second]++;
}
for(ll i = 0;i < N;i++){
row[arr[i].first] += (colcnt[arr[i].second] - 1);
col[arr[i].second] += (rowcnt[arr[i].first] - 1);
}
ll sum = 0;
for(ll i = 0;i < N;i++){
sum += (row[arr[i].first] - (colcnt[arr[i].second] - 1));
sum += (col[arr[i].second] - (rowcnt[arr[i].first] - 1));
}
cout<<sum / 2<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |