Submission #372343

#TimeUsernameProblemLanguageResultExecution timeMemory
372343mariowongStar triangles (IZhO11_triangle)C++14
0 / 100
3 ms364 KiB
#include <bits/stdc++.h> using namespace std; int n,l; long long ans; pair<int,int> a[300005]; map <int,int> ct; int main(){ freopen("triangles.in","r",stdin); freopen("triangles.out","w",stdout); ios::sync_with_stdio(false); cin >> n; for (int i=1;i<=n;i++){ cin >> a[i].second >> a[i].first; ct[a[i].second]++; } sort(a+1,a+1+n); l=1; for (int i=1;i<=n;i++){ if (i == n || a[i+1].first != a[i].first){ for (int j=l;j<=i;j++){ ans+=(long long)(i-l)*(long long)(ct[a[j].second]-1); } l=i+1; } } cout << ans << "\n"; return 0; }

Compilation message (stderr)

triangle.cpp: In function 'int main()':
triangle.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  freopen("triangles.in","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:10:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  freopen("triangles.out","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...