Submission #372343

# Submission time Handle Problem Language Result Execution time Memory
372343 2021-02-27T18:20:49 Z mariowong Star triangles (IZhO11_triangle) C++14
0 / 100
3 ms 364 KB
#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

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 time Memory Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -