Submission #1243502

#TimeUsernameProblemLanguageResultExecution timeMemory
1243502snowysmoStar triangles (IZhO11_triangle)C++20
100 / 100
363 ms7160 KiB
#include<bits/stdc++.h> #define ll long long #define endl '\n' using namespace std; int main(){ int n; cin>>n; map<ll, pair<ll, ll>> mp; ll a[n+1], b[n+1]; for(int i=1;i<=n;i++){ cin>>a[i]>>b[i]; ll x=a[i], y=b[i]; if(!mp.count(x)) mp[x].first=1, mp[x].second=0; else mp[x].first++; if(!mp.count(y)) mp[y].first=0, mp[y].second=1; else mp[y].second++; } ll ans=0; for(int i=1;i<=n;i++){ ll x=a[i], y=b[i]; ll xx=mp[y].second-1, yy=mp[x].first-1; ans+=xx*yy; } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...