Submission #685270

#TimeUsernameProblemLanguageResultExecution timeMemory
685270WhiteStar triangles (IZhO11_triangle)C++14
100 / 100
210 ms24344 KiB
#pragma GCC optimize ("O3") #include <bits/stdc++.h> #define endl "\n" using namespace std; pair<long long,long long>red[300005]; long long ans=0,cnt=0; vector<long long>x[300005]; map<long long,long long>y; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin>>n; for(int i=0;i<n;i++){ long long A,B; cin>>A>>B; red[i]=make_pair(A+1000000000,B+1000000000); y[B+1000000000]++; } sort(red,red+n); x[0].push_back(red[0].second); for(int i=1;i<n;i++){ if(red[i].first==red[i-1].first){ x[cnt].push_back(red[i].second); }else{ cnt++; x[cnt].push_back(red[i].second); } } for(int i=0;i<=cnt;i++){ for(int j=0;j<x[i].size();j++){ ans+=(x[i].size()-1)*(y[x[i][j]]-1); } } cout<<ans<<endl; return 0; }

Compilation message (stderr)

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