Submission #679984

#TimeUsernameProblemLanguageResultExecution timeMemory
679984KarukStar triangles (IZhO11_triangle)C++14
100 / 100
537 ms38920 KiB
#include<bits/stdc++.h> using namespace std; vector<int>x[600001]; vector<int>y[600001]; int main() { int n; cin>>n; set<int>s; pair<int,int>a[n]; for(int i=0;i<n;i++) { int x,y;cin>>x>>y; a[i]={x,y}; s.insert(x); s.insert(y); } vector<int>v; for(int i:s)v.push_back(i); map<int,int>m; for(int i=0;i<v.size();i++) { m[v[i]]=i; } for(int i=0;i<n;i++) { a[i].first=m[a[i].first]; a[i].second=m[a[i].second]; x[a[i].first].push_back(a[i].second); y[a[i].second].push_back(a[i].first); } long long ans=0; for(int i=0;i<n;i++) { ans+=(x[a[i].first].size()-1)*(y[a[i].second].size()-1); } cout<<ans<<endl; return 0; } /** 3 0 0 1 0 0 1 */

Compilation message (stderr)

triangle.cpp: In function 'int main()':
triangle.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i=0;i<v.size();i++) {
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...