# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
497907 | Aktan | Star triangles (IZhO11_triangle) | C++14 | 1 ms | 204 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define ft first
#define sc second
using namespace std;
const int mod=1e9+7,INF=1e17;
int a[300005],b[300005];
multiset<pair<int,int>> p;
map<int,int> m,m1;
main(){
ifstream fin("triangles.in");
ofstream fout("triangles.out");
int n,ans=0;
fin >> n;
for(int i=0;i<n;i++){
fin >> a[i] >> b[i];
p.insert({a[i],b[i]});
m[a[i]]++;
m1[b[i]]++;
}
for(auto x : p){
ans+=(m[x.ft]-1)*(m1[x.sc]-1);
}
fout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |